Where are string literals stored?

Started by
0 comments, last by Fruny 18 years, 8 months ago
case 55:
     strcpy(goLookMessage->lacLineName, "You see a crate.");
     sDealWithMessage(flag_ChnDefault,goColor,"You see a crate.");
break;
Are string literals like this stored in the heap or stack?
Advertisement
Neither. They are embedded in the code of the program itself, and may be placed in read-only data sections, or even live among your functions in code sections. It depends on the compiler and, ultimately, on the linker.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

This topic is closed to new replies.

Advertisement