incrementing an array of pointers in C

后端 未结 5 1971
滥情空心
滥情空心 2020-12-20 20:01

this is probably an essentially trivial thing, but it somewhat escapes me, thus far..

char * a3[2];
a3[0] = \"abc\";
a3[1] = \"def\";
char ** p;

5条回答
  •  無奈伤痛
    2020-12-20 20:07

    Try

    char *a3Ptr = a3;
    printf("%p - \"%s\"\n", a3, *(++a3Ptr));
    

    In C, a char array[] is different from char*, even if you can use a char* to reference the first location of an array of char.

    aren't both "p" and "a3" pointers to pointers?

    Yes but a3 is constant. You can't modify it.

提交回复
热议问题