1.int *p与int* p有什么不同?
从语法上讲,没有区别。
从命名规范上讲,int *p和int* p后者比前者更好理解为指针。
int *p;可能会被理解为一个变量,名为*p
int* p;很直观的被理解为一个指针,名为p
2.->是(*p.)的简写
struct point{ int x; int y;
}
如 struct point *p;p是一个结构体指针,
取其成员x有两种方法
1.(*p).x
2. p->x;
3.结构体的大小(字节对齐)
结构体变量的大小,必须是最宽基本类型数据类型的整数倍
4.字符数组赋值,只能在声明时。
//字符串数组赋值,只能在声明时 char a[10] = "jimmy"; //a="Tom";不可以 //可以修改内容 a[0] = 'e'; // 重新赋值 strcpy(a, "Tom");
字符指针能多次赋值
//字符指针 char *p = "jimmy"; p = "Tom";
5.#ifdef _cplusplus标识支持C++语法
#ifdef __cplusplus extern "C" { #endif void C_fun(); #ifdef __cplusplus } #endif