Possible Duplicate:
What is the difference between char s[] and char *s in C?
There’s a program:
#include<stdio.h>
int main()
{
char str[20] = "Hello";
char *const p=str;
*p='M';
printf("%s\n", str);
return 0;
}
This prints Mello as the answer.. But since p is a constant pointer, shouldn’t it give an error?
It’s a contant pointer, exactly. You can’t change where it points. You can change what it points.
The easiest way to memorize the syntax is to not memorize it at all. Just read the declaration from right to left 🙂