标签:
The difference here is that :
char *s = "hello,world!";
will place hello,world in read-only part of the memmory and makes s a pointer to that. making any writing operation on this illigal.
while:
char s[] = "hello,world!";
will puts the hello,world in read-only memmory and copies the string to newly allocated memmory thus making :
s[0] = ‘j‘;
legal.
from:http://stackoverflow.com/questions/1704407/what-is-the-difference-between-char-s-and-char-s-in-c
difference between char *s and char s[ ]
标签:
原文地址:http://www.cnblogs.com/yongjiuzhizhen/p/4298966.html