Character array and base address

in case of int array whenever we give the array name it shows only base address but in case of the character array it is showing whole content .HOw?and why?

Hi, the basic difference between a character array and an integer array is the terminating null character ‘\0’ in case of character array which is appended by default.
The arguments you pass (eg integers and characters) undergo array-to-pointer conversion, to void* and char* respectively.
In the const void* version, the pointer is displayed, while with the const char* version, the string is displayed up to the null terminator.
The reason is that operator<< overloaded for const char* which prints each character till it encounters \0. There is no such overload corresponds to int[N] which prints each element in it. Instead when you write cout << numbers, it invokes operator<< which is overloaded for void*, and which prints the address.

1 Like