The code you posted actually
shouldn't work, because string literals are
const. Some compilers will let you get away with that because older code uses it, but you shouldn't do that in any code that you write.
The proper way would be to do this:
1 2
|
const char * months[12] = // note the const
{"January" , "February", "March", "April", "May", ..., "December"};
|
As for your actual question, the string data doesn't go in a variable like it does when you say
char foo[20] = "whatever";
Instead, string literals used by the program get stored somewhere separately in the program's executable. Like if you opened up your .exe file in a hex editor and looked through it, you would find "January", "February", etc written in it somewhere, along with all the other string literals your program uses
Therefore the computer doesn't need to reserve any space for the characters because the characters already exist in the exe. You just point to those already-existing characters.