What happens when a char array gets initialized from a string literal?
问题 As I understand it, the following code works like so: char* cptr = "Hello World"; "Hello World" lives in the .rodata section of the program's memory. The string literal "Hello World" returns a pointer to the base address of the string, or the address of the first element in the so-called "array", since the chars are laid out sequentially in memory it would be the 'H'. This is my little diagram as I visualize the string literal getting stored in the memory: 0x4 : 'H' 0x5 : 'e' 0x6 : 'l' 0x6 :