There is an interesting point here. What you have actually are just 3 pointers all pointing to const litteral strings. So the compiler is free to create one single string for "First"
and have both str1
and str3
point there.
This would be a completely different case:
char str1[] = "First";
char str2[] = "Second";
char str3[] = "First";
I have declared 3 different char arrays initialized from litteral strings. Test it, and you will see that the compiler have assigned different addresses for the 3 different strings.
What you should remember from that: pointers and arrays are different animals, even if arrays can decay to pointers (more on it in this post from the C FAQ)