Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 1
    what you call "static" space is, from the point of view of the executable file, the "data" (or "rodata") segment. It's effectively a global variable, just you're not making it (globally) visible / you're not giving it a (global) name. Commented Aug 9, 2013 at 14:35
  • The string is not necessarily read-only. It can be, and in environments where this is possible it probably is. See stackoverflow.com/questions/1704407/… Commented Aug 9, 2013 at 14:54
  • Just to amplify here, the "hello" is constructed when the program is linked. The section of code containing the assignment need never be called, but the string will be available. Commented Aug 9, 2013 at 15:31
  • Note in C++ this uses a deprecated conversion see: C++ warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] Commented Jun 17, 2015 at 11:52