开发者

Location of static pointed memory

I read that pointers passed by malloc() & calloc() get allocated memory dynamically from the heap.

char *Name="Ann";
  1. In this case, is the static string {'A','n','n','\0'} also stored in the heap?开发者_如何转开发
  2. Can I modify the string using the pointer?


  1. No, the string is allocated statically. (C99, §6.4.5/5)
  2. Attempting to modify a string literal gives undefined behavior. (§6.4.5/6)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜