Reputation: 501
As I have learnt,array name acts like a pointer to first element.But:
int c[]={0,1,2};
printf("%d \t %d",c,&c[0]); //Different values,Why?
Also then why *c=0
?
Upvotes: 0
Views: 492
Reputation: 363818
Just a guess: you're on a platform with 64-bit pointers and 32-bit int
. Your code passes two pointer values to printf
, which then interprets these as int
values; that might print the two halves of a 64-bit pointer as two separate integers.
You should print pointers with %p
, not %d
, after casting them to void*
.
Upvotes: 11