"Gautam" <ga********@yahoo.com> wrote in message
news:44*************************@posting.google.co m...
i was thinking of declaring a string . .
two ideas came in my mind
i) char a[10] = "ilovemyc";
ii) char *p = "ilovemyc";
how can we differentiate the above two declarations?
In the first case, you are declaring a 10-element array of char and
initializing it's contents with the string "ilovemyc"; it is equivalent to
typing
char a[10] = {'i','l','o','v','e','m','y','c',0,0};
You may modify the contents of this array.
In the second case, you are declaring a pointer to char and initializing it
to point to the base of a 9-element array of char that is stored in
non-writable memory; it is equivalent to typing
char *p = 0x........
where 0x........ is the address of the first element of the string.
You may not modify the contents of the string being pointed to.