String Literals
String Literals
1 | |
Know: The memory address of the first character of the string literal “Hello” is assigned to the pointer variable text.
However: This string literal is stored in read-only memory.
Thus: Cannot modify the literal. Doing so leads to UB.
Modern Standard: You are not supposed to assign a literal to non-const pointer.
1 | |
Why in ROM: Search engine your way
Want to Modify?: Declare it as a character array instead.
1 | |
String Literals
http://example.com/p/ea99e230968447eab9eece94f1f5f837/