Posted by: testdirector August 4, 2005
Login in to Rate this Post:
0
?
I've already a got a lesson trying to be a an Almighty, but still I've some juice to continue the discussion. Here is what I understand
1.
const char *p = "abcde"; // p points to a string whose content cannot be modified */
char p[] = "pqrst";
p = q; // the pointer can be modified, not the content
p[0] = 0; // error
2.
char *const p = "abcde";
char q[] = "pqrst";
p = q; /* compile error: p is a constant */
but
p[0] = 0; /* no compile error, but compiler dependant, may cause a fault */
3.
const char *const p = "abcde";
char q[] = "pqrst";
p = q; /* compile error: p is a constant */
p[0] = 0; /* compile error */