linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Query: Declaring arrays as extern
@ 2011-12-22  9:04 viresh kumar
  2011-12-22  9:04 ` viresh kumar
  2011-12-23 18:27 ` Alok Singhal
  0 siblings, 2 replies; 4+ messages in thread
From: viresh kumar @ 2011-12-22  9:04 UTC (permalink / raw)
  To: linux-c-programming
  Cc: Shiraz HASHIM, pratyush.anand, vipin.kumar, Viresh KUMAR,
	Vipul Kumar SAMAR, bhavna.yadav, Deepak SIKRI, Armando VISCONTI,
	Bhupesh SHARMA, rajeev, Amit VIRDI

Hi,

I can observing an behavior which i am not able to explain.

file1.c

/* global array */
int arr[10];

void main()
{
    printf("addres of array is %p", arr);
}


file2.c
extern int arr[];

void main()
{
    printf("addres of array is %p", arr);
}


file3.c
extern int *arr;


void main()
{
    printf("addres of array is %p", arr);
}




Now, value printed with file 1 and 2 are same, but extern int *arr
doesn't work at all. The address shown is just something else.

I know we pass array addresses to routines this way only, but with
extern it is just not working.

Can somebody please explain it?

--
viresh

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-12-23 18:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-22  9:04 Query: Declaring arrays as extern viresh kumar
2011-12-22  9:04 ` viresh kumar
2011-12-23 16:38   ` subin gangadharan
2011-12-23 18:27 ` Alok Singhal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).