In my quest to understand pointers, I have started to wonder something. In the following lines of code:
The program outputs 'P' because P is the value being pointed to by MyName. Is that correct?Code:char * MyName = "Paul"; cout << *MyName << endl;
This should print the address that MyName points to shouldn't it? But instead it prints the string "Paul". Is this because cout is smart enough that when it gets a char *, it will start from that address and keep printing values until it finds a \0?Code:char * MyName = "Paul"; cout << MyName << endl;
Also, when I write
char * MyName = "Paul"
Does MyName actually hold the address of the static string "Paul" in memory? Thanks for any help!