I was just playing with pointers and arrays when I was confused with this code that I tested.
#include <iostream> using namespace std; int main(void) { char a[] = "hello"; cout << &a[0] << endl; char b[] = {'h', 'e', 'l', 'l', 'o', '\0'}; cout << &b[0] << endl; int c[] = {1, 2, 3}; cout << &c[0] << endl; return 0; }
I expected this to print three addresses (from [0], b [0] and c [0]). But the result:
hello hello 0x7fff1f4ce780
Why is this for the first two cases with char, '&' gives a whole line, or am I missing something here?
source share