“*”的几种用途
-
乘法运算符
int x = 1; int y = 2; int z = x * y;
-
定义新的类型
char x; char* x;
-
取值运算符
-
- 指针类型的变量 int* a =(int*)1; printf("%x \n",(a +1)); 10: int a =(int*)1; 00401028 mov dword ptr [ebp-4],1 11: printf("%x \n",*(a +1)); 0040102F mov eax,dword ptr [ebp-4] 00401032 mov ecx,dword ptr [eax+4] 00401035 push ecx 00401036 push offset string "%x \n" (0042201c) 0040103B call printf (00401070) 00401040 add esp,8 当然这里运行的时候肯定出错 因为 1 是一个异常的不存在的地址
-
探测 * 指针类型 的类型
int*** a;
int***** b;
int******* c;
int* d;
//int x = *(a+1);
//int x = *(b++);
//int x = *(c-5);
//int x = *(d+6);
//总结
// *加指针类型 的类型是 指针类型减去一个*
取值运算符举例
int x=1; int x =1;
int* p = &x; int* p = &x;
printf("%x %x \n",p,*(p)); int** p2 = &p;
*(p)=2; int*** p3 = &p2;
printf("%d \n",x); int r = *(*(*(p3)));
printf("%d \n",r);