Location of static pointed memory
I read that pointers passed by malloc() & calloc() get allocated memory dynamically from the heap.
char *Name="Ann";
- In this case, is the static string {'A','n','n','\0'} also stored in the heap?开发者_如何转开发
- Can I modify the string using the pointer?
- No, the string is allocated statically. (C99, §6.4.5/5)
- Attempting to modify a string literal gives undefined behavior. (§6.4.5/6)
精彩评论