- char data[] = “data”;
- data: [D] [A] [T] [A] [\0]
- so , char data[] is a array holding the data\0
- the individual characters can be modified
- but data will always refer to the same storage
- char *data = “data”;
- [data] –> [D] [A] [T] [A] [\0]
- so, char *data is a pointing to a string constant
- the pointer can be modified to point to other location
- modifying the string constant gives undefined result (SIGSEGV in gcc)
No comments:
Post a Comment