Query: Declaring arrays as extern

viresh kumar <[email protected]> Thu, 22 Dec 2011 14:34:05 +0530
Newsgroups org.kernel.vger.linux-c-programming
Message-ID <CAOh2x=ktZBLD2KDOxdBGtz0Acqc0RDkA-VrCCCO2Nby8D=2FRg@mail.gmail.com>
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