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',''} 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)
  • 链接地址: http://www.djcxy.com/p/82518.html

    上一篇: 局部变量内存和malloced内存位置

    下一篇: 静态尖端内存的位置