pavunkumar said:
Dear Friend
Please Explain about this things
I have character pointer variable
char *p="string";
char *s ="string";
If I print the both variable of the address
It is print same address why ?
Section 6.4.5p5 of the standard explains how the characters that are
specified by a string literal are used to initialize an array. Then, in
paragraph 6, it goes on to say "It is unspecified whether these arrays
are distinct provided their elements have the appropriate values. ...".
It's not just that s == p; you can even have two different string
literals overlapping. If we add the following declaration:
char *t = "this is a string";
It's quite possible for a conforming implementation to have the string
pointed at by p and q be the the final portion of the same string that t
points at, so that t+10 == p; there are real implementations which do
precise this, to save space.