首页 > 其他 > 详细

difference between char *s and char s[ ]

时间:2015-02-24 22:10:39      阅读:298      评论:0      收藏:0      [点我收藏+]

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!