一 #define的多分支:
#ifdef AAA
a=1;
#elif BBB
a=2;
#elif CCC
a=3;
#else
a=4;
#endif
二:数值的范围判断:
因为计算机不能识别连续的判断符所以不能写成if(0<a<10),应该写成if(0<a&&a<10)
三字符串处理时数据类型 char*与unsigned char*:
8位无符号数值的时候,用unsigned char;表示8位有符号数值或者ASCII字符的时候,用char.从一串字符串中取出字符既要当字符使用的,也有当无符号8位数值使用的
三C语言编程时,各种类型的变量该如何初始化?
字符数组由多个字符(‘ ’)组成,初始化用char str[4+1]="";或者用memset,数组个数定义成+1是因为字符串都以‘ ’结尾多一个字节。
指针:初始化NULL;动态分配释放后也要NULL;指针作为函数形参已经退化成数组,但本质上还是一个4字节的地址。
结构体:初始化用memset