void main(){ // the pointer array char* arry[] = { "hello", "world", "haha" }; for (int i = 0; i < 3; i++){ printf("string:%s,address:%p\n", arry[i], arry[i]); } // the array‘s pointer int a[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; printf("a[0]->%d\n",*a);// 0 printf("a[1]->%d\n", *(a + 1));// 1 printf("a[2]->%d\n", *(a + 2));// 2 int(*p)[10]; //p = a; error: "int*" can not be assigned to "int(*)[10]" p = &a; printf("**p->%d\n", **p);// 0 printf("(*p)[0]->%d\n", (*p)[0]);// 1 printf("*(*p + 1)->%d\n", *(*p + 1));// 1 printf("(*p)[1]->%d\n", (*p)[1]);// 1 printf("*(*p + 2)->%d\n", *(*p + 2));// 2 printf("(*p)[2]->%d\n", (*p)[2]);// 1 //size printf("sizeof(p)->%d\n", sizeof(p));// 4 printf("sizeof(*p)->%d\n", sizeof(*p));// 40 system("pause"); }
[C++] the pointer array & the array's pointer
时间: 2024-12-15 02:55:20