1

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!

Community
  • 1
  • 1
Shehbaz Jaffer
  • 1,944
  • 8
  • 23
  • 30

0 Answers0