arrays and addresses

in my case, grid is the address of the first element of array grid;
so why the address of the address equals the same address?

1
2
3
4
5
6
7
8
9
#include <iostream>
using namespace std;

int main()
{
int grid[10]={0};
cout << grid << " " << &grid; // they are the same
}
grid is the address of the first element of array grid;


grid is not an address, an address is some location in memory eg: 0x23f23f23f ( hex )
grid is an "identifier" ( or more precise: a constant pointer ) which contains the address of grid[0], ( &grid[0] )

grid, &grid and &grid[0] are all the same, they are used to refer to the address of the first element of the grid array
Topic archived. No new replies allowed.