Query: Declaring arrays as extern

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux