I am learning pointers and I dont understand how pointers work with C-style strings. Why are these two equivalent?
char a[] = "Gme";
char* p = a; //Why am I allowed to assign "Gme" to a pointer (pointer is an address)
cout << p << " " << *(p+1); //Why does it print "gme" with "cout<<p" (I mean, I am printing an address)?
and
char a[] = "Gme";
char* p = &a[0]; // How is this the same as char* p = a;
cout << p << " " << *(p+1);
Overall, I do not understand how pointers work with strings. How are chars stored in memory? If we consider string as an array of chars,why can't I print the address of a char element?
Thanks in advance :)