char amessage[]="now is the time"; char *pmessage= "now is the time";
amessage is 1)an array just big enough to hold the sequence of characters and '\0' that initialises it 2)Individual characters within the array may be changed but amessage will always refer to the same storage i.e. amessage cant point to some other location;so incrementing and decrementing it is not allowed
pmessage is 1)a pointer initialised to point to a string constant storage in read only area 2)The pointer may be modified to point elsewhere;but the result is undefined is we try to modify string constants.
char amessage[]="now is the time";
ReplyDeletechar *pmessage= "now is the time";
amessage is
1)an array just big enough to hold the sequence of characters and '\0' that initialises it
2)Individual characters within the array may be changed but amessage will always refer to the same storage i.e. amessage cant point to some other location;so incrementing and decrementing it is not allowed
pmessage is
1)a pointer initialised to point to a string constant storage in read only area
2)The pointer may be modified to point elsewhere;but the result is undefined is we try to modify string constants.
http://techblog.rosedu.org/arrays-vs-pointers.html
ReplyDelete