I am printing out addresses and strings from the following two declarations and initializations:
char * strPtr = (char *) "This is a string, made on the fly.";
char charArray [] = "Chars in a char array variable.";
When printed, the following output occurs with wildly different addresses for the variables charArray and strPtr. The question is, "Why?"
Printing:
printf( "%10s%40s%20p\n", "strPtr", strPtr, &(*strPtr));
printf( "%10s%40s%20p\n", "charArray", charArray, charArray);
Output:
strPtr This is a string, made on the fly. 0x400880
charArray Chars in a char array variable. 0x7fff12d5ed30
The different addresses, as you see, are: 0x400880 vs. 0x7fff12d5ed30
The rest of the variable declared before this have addresses like that of charArray.
Again, the question is, "Why are the addresses so different?" Thanks for any assistance.

const char *str = "string";. This helps prevent the undefined behaviour of attempting to modify string literals.