The following is the C code:
char *ptr[100];
printf("%s\n",*ptr++);
My question is: we know that array name is not a variable (Ritchie's book "The C programming language" Page 99), so if we define
int *pa,a[5];
This is legal:
pa = a; pa++;
while this is illegal:
a++;
Here char *ptr[100]
defines a char pointer array, so ptr
represents the initial address of the array. For the above code, if *ptr++
means *(ptr++)
, this is illegal because array name cannot be used as a variable, and also it's meaningless because *(ptr++)
still gets an address as opposed to %s
. However, if *ptr++
means (*ptr)++
, it also looks strange... Can anyone help to understand this?
The above is my thinking process, my question is: how can *ptr++
give us a string as the code printf("%s\n",*ptr++);
says?