Why the entire string is displayed as outcome? Why address of 1st character not getting printed? How can I print address of 1st character? Please help me.
#
The << operator on std::cout will treat a char* as a null-terminated string. You will need to cast it to a void* to print the pointer value.
<<
std::cout
char*
void*
Try this:
#include <iostream> int main() { char x[6] = "hello"; std::cout << static_cast<void*>(x); }