Possible Duplicate:
Pointer-array-extern question
We have two files:
file1.c
int myarray[10];
file2.c
extern int *myarray;
void foo()
{
myarray[0]=10;
}
void main()
{
foo();
}
This program gives a segmentation fault. However If we change the extern int *myarray
to extern int myarray[]
, the program works.
Please explain. Thanks!