C和C++编程和学习文档
C和C++编程和学习文档
1 :指针变量名称以p为首字符,这是程序员通常在定义指针时的一个习惯
2 :har * p; (int *)p 把p强制转换为int型
3.1 :指针的问题:指针应用时最好给予定义(初始化)这样可以保证指针的指向是程序员自己能够把握的。
3.2 :指针的越界,这恐怕是最难查出的吧!
3.3 :指针的局部变量问题。局部的指针变量会被程序自动释放,若程序员引用此类指针就会出错。2007-9-1
4.二维指针的应用实例:
#include <stdio.h>
#include <string.h>
void sort(char (*client)[10]);
void main()
{
int temp;
char client[3][10];
char (*pClient)[10] = NULL;
for( temp = 0; temp < 3; temp++ )
{
gets(client[temp]);
}
pClient = client;
sort(pClient);
for( temp = 0; temp < 3; temp++ )
{
puts(*(pClient + temp));
}
}
void sort(char (*client)[10])
{
//冒泡算法的明了写法
int temp1, temp2;
&n
相关文档:
assert
函数名: assert
功 能: 测试一个条件并可能使程序终止
用 法: void assert(int test);
程序例:
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
struct ITEM {
int&n ......
/* =========================================================================== */
/* Project: s3c44b0_lib & ......
//-----------------------------------------------------------------------------------------------------
//BY:yuyongbao
//QQ:673360056
//-----------------------------------------------------------------------------------------------------
#include "tetris.h"
Tetris::Tetris(QWidget *parent)
&nbs ......
//-----------------------------------------------------------------------------------------------------
//BY:yuyongbao
//QQ:673360056
//-----------------------------------------------------------------------------------------------------
#include "tetrixboard.h"
/* ZShape , &nb ......
以前学生时代的时候就有遇到过这个问题,不过没去深究;
现在也是老问题,其实很简单,就是为了防止#include两个头文件的时候,把第一个头文件的最后一行和 第二个头文件的第一行拼接成一行;呵呵,其实很多问题都很简单,而且很隐蔽,只是我们很多时候没去注意! ......