1

In C,

char a[3] = "a";
printf("%u %u",a,&a);

a and &a both print the address.
I learned that an array name represents the address of the first element.

But in C++,

char arr[30] = "string";
cout << arr;

When I tried to print this, I found out that the computer prints strings, not an address.
Why does the array name print strings, not an address? Why is this happening in c++?

  • 1
    An array is an array and a pointer is a pointer, an array is not a pointer. Arrays can implicitly convert to pointers to their first element but they are not pointers. – François Andrieux Apr 18 '22 at 02:11

0 Answers0