could you tell my why the value of a referenced array and the value of the array itself has the same value?
i know a is a type of int* but with &a it should be int** or am i wrong?? so the value should be a pointer to the a int pointer. example code:
#include <stdio.h>
int main()
{
int a[10];
printf("a without ref.: 0x%x\n",a);
printf("a with ref.: 0x%x\n",&a);
return 0;
}
http://ideone.com/KClQJ
Name of the array decays to an pointer to its first element in this case.
Name of the array will implicit convert to a pointer ,except for two situation ,the one situations is "&array",the other is "sizeof(array)".In both cases,name of the array is a array ,not a pointer .
For example:
int a[10];
int *p;
p = a; //a is a pointer
p = &a; //a is a array,&a is a constant pointer
sizeof(a); //a is array
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With