Tuesday, 15 July 2014

c - array,pointer address value confusion -



c - array,pointer address value confusion -

this question has reply here:

how come array's address equal value in c? 7 answers

in running code below , got output

num= 2359120, addr of num=2359120, *num=10,addr of num[0]=2359120

i can't comprehend how num , &num have same value. help, please? know name of array pointer itself

#include <math.h> #include<stdio.h> main() { int num[]={10,20,30,40,50}; printf("num= %d, addr of num=%d, *num=%d,addr of num[0]=%d\n",num,&num,*num,&num[0]); }

name of array num same address of array &num same address of first element &num[0] , hence, output.

c pointers

No comments:

Post a Comment