指针我们已经学习的差不多了,今天我来给大家分享几个经典的题目,来让我们相互学习️️️

int main(){int a[4] = { 1, 2, 3, 4 };int* ptr1 = (int*)(&a + 1);int* ptr2 = (int*)((int)a + 1);printf("%x,%x", ptr1[-1], *ptr2);return 0;}

#include int main(){int a[3][2] = { (0, 1), (2, 3), (4, 5) };int* p;p = a[0];printf("%d", p[0]);return 0;}

int main(){int a[5][5];int(*p)[4];//数组指针p = a;//类型合适吗? //a - int(*)[5]//p - int(*)[4]printf("%p, %d\n", &p[4][2] - &a[4][2], &p[4][2] - &a[4][2]);////%p是打印地址,认为内存中存储的补码就是地址//return 0;}

图解:

int main(){int aa[2][5] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };int* ptr1 = (int*)(&aa + 1);int* ptr2 = (int*)(*(aa + 1));printf("%d,%d", *(ptr1 - 1), *(ptr2 - 1));return 0;}

#include //阿里的笔试题int main(){char* a[] = { "work","at","alibaba" };char** pa = a;pa++;printf("%s\n", *pa);return 0;}

相信大家一定从今天的题目当中收获满满,希望大家有美好的一天!