```c
int main()
{
int a[4] = { 1, 2, 3, 4 };
int *ptr1 = (int *)(&a + 1);
int *ptr2 = (int *)((int)a + 1);// 若a=ox100 (int)a+1=101
printf( "%x,%x", ptr1[-1], *ptr2);// 4 2000000
return 0;
}
int main()
{
int a[5][5];
int(*p)[4] = (int (*)[4])a;
printf( "%p,%d\n", &p[4][2] - &a[4][2], &p[4][2] - &a[4][2]);//
return 0;
}
int main()
{
int aa[2][5] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int *ptr1 = (int *)(&aa + 1);//&aa aa代表整个数组 取出整个数组的地址
int *ptr2 = (int *)(*(aa + 1));//aa+1 第二行地址
printf( "%d,%d", *(ptr1 - 1), *(ptr2 - 1));// 5 10
return 0;
}
int main()
{
char *c[] = {"ENTER","NEW","POINT","FIRST"};
char**cp[] = {c+3,c+2,c+1,c};
char***cpp = cp;
printf("%s\n", **++cpp); //POINT
printf("%s\n", *--*++cpp+3);// ER *(--*(++CPP))+3
printf("%s\n", *cpp[-2]+3);// *(*(CPP-2))+3 ST
printf("%s\n", cpp[-1][-1]+1);// *(*(CPP-1)-1)+1 //EW
return 0;
}
char *myString()
{
char buffer[6] = {0};
char *s = "Hello World!";
int i = 0;
for (i = 0; i < sizeof(buffer) - 1; i++)
{
buffer[i] = *(s + i);
}
return buffer;//return char类型
}
int main()
{
printf("%s\n", myString());//乱码
return 0;
}
//局部变量分配的内存在使用完之后应该及时释放