- Subject: Query: Declaring arrays as extern
- From: viresh kumar <viresh.linux@xxxxxxxxx>
- Date: Thu, 22 Dec 2011 14:34:05 +0530
- Cc: Shiraz HASHIM <shiraz.hashim@xxxxxx>, "pratyush.anand" <pratyush.anand@xxxxxx>, "vipin.kumar" <vipin.kumar@xxxxxx>, Viresh KUMAR <viresh.kumar@xxxxxx>, Vipul Kumar SAMAR <vipulkumar.samar@xxxxxx>, bhavna.yadav@xxxxxx, Deepak SIKRI <deepak.sikri@xxxxxx>, Armando VISCONTI <armando.visconti@xxxxxx>, Bhupesh SHARMA <bhupesh.sharma@xxxxxx>, rajeev <rajeev-dlh.kumar@xxxxxx>, Amit VIRDI <Amit.VIRDI@xxxxxx>
- List-id: <linux-c-programming.vger.kernel.org>
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
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
[Linux Assembler]
[Git]
[Kernel List]
[Fedora Development]
[Fedora Announce]
[Autoconf]
[Yosemite Campsites]
[Yosemite News]
[GCC Help]