comp.lang.c
[Top] [All Lists]

Re: why do the following crash

Subject: Re: why do the following crash
From: "Bartc"
Date: Mon, 31 Mar 2008 16:03:13 GMT
Newsgroups: comp.lang.c


<parag_paul@xxxxxxxxxxx> wrote in message
news:f5b46a43-52b2-45e2-8bfe-979c20e33dc7@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> File1.c
>
>  int arr[80];
>
> File2.c
>
>  extern int *arr;
>  int main()
>  {
>      arr[1] = 100;
>      return 0;
>  }

The declarations for the arr variable don't match.

Try extern int arr[80] in File2.c.

(I know arrays and pointers are /supposed/ to be interchangeable. But there
is a subtle difference between: int a[80] and int *a)

-- 
Bart




<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy