Ok, since this code is too long for you to read, I labelled the code. Firstly, i created a pointer called user1 while defining function userpass. The function accepts the memory location of 2 arrays as it's arguments which get transferred to user1 and pass1 pointers. So my question is at the "do" loop, which i marked with another comment "!!!!!!!". When i "cout" user1, it displays the username i entered at the do loop marked with comment "AAAAAAAAA". My question is, why doesnt the cout statement display the memory address of the "user" string from the main(), and why does it display a string instead?
> My question is, why doesnt the cout statement display the memory address of the "user" string
> from the main(), and why does it display a string instead?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
constchar cstr = "abcd" ;
constvoid* p = cstr ;
std::cout << cstr ;
// overload resolves to: free function which prints a c-style string
// std::ostream& operator<< ( std::ostream&, const char* ) ;
std::operator<< ( std::cout, cstr ) ;
std::cout << p ;
// overload resolves to: member function which prints the value of a pointer
// std::ostream::operator<< ( const void* ) ;
std::cout.operator<< (p) ;