String Literals and Implicit Char Arrays?

closed account (zb0S216C)
I'm currently reading the C++ Primer Plus 5th Edition book, and I'm reading about strings (not the STL std::string). According to this book, character literals don't have an address, but string literals do. Here's a quote from the book:

"ā€œSā€ actually represents the memory address at which the string is stored. (sic)"

So I dug a little deeper (since it doesn't go into any more detail), and found that this std::cout statment was valid:

std::cout << "String"[2] << std::endl;

It turns out that this statement prints 'r' to the screen. Since I was able to use the sub-script operator on the string, I instantly assumed that "String" was in fact an array of chars that was constructed implicitly by the compiler. Am I right?

Wazzak
Last edited on
Topic archived. No new replies allowed.