总而言之一句话,就是*(malloc_space + 0)和malloc_space[0]是基础的,用malloc_space的等价语句不断替换
代码
#include <stdio.h>
#include <stdlib.h>
int main()
{
int *malloc_space = (int *)malloc(sizeof(int)*3);
*(malloc_space + 0) = 0;
*(malloc_space + 1) = 1;
*(malloc_space + 2) = 2;
int a = 123;
int *a_pointer = &a;
int b = 321;
int *b_pointer = &b;
int *px[3] = { malloc_space, a_pointer, b_pointer };
printf("%d\n",*(malloc_space + 0));
printf("%d\n",malloc_space[0]);
printf("%d\n",px);
printf("%d\n",malloc_space);
printf("%d\n",*px);
printf("%d\n",px[0]);
printf("%d\n",*(*px + 0));
printf("%d\n",(*px)[0]);
printf("%d\n",*(px[0] + 0));
printf("%d\n",px[0][0]);
free(malloc_space);
return 0;
}
运行结果
0
0
157761664
22737504
22737504
22737504
0
0
0
0