0

Why right value and left value in array are the same?

Refer to the code: why &a and a have the same value?

CODE:

int main()
{
    int a[4];
    *a = 3;
    printf("&array: %p    array: %p   array[0]: %d", &a, a, *a);
    return 0;
}

OUTPUT:

&array: 000000000023FE50 array: 000000000023FE50 array[0]: 3

Sourav Ghosh
  • 133,132
  • 16
  • 183
  • 261
Mike
  • 1

1 Answers1

1

Here, &a and a gives the same output because, in C, array name behaves (or better, gets evaluated to) as the address of the first element of the array.

Sourav Ghosh
  • 133,132
  • 16
  • 183
  • 261
  • thank's for the link [link](http://stackoverflow.com/questions/2528318/how-come-an-arrays-address-is-equal-to-its-value-in-c) – Mike Jun 02 '15 at 08:17