Re: why do the following crash




<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



.



Relevant Pages

  • Re: External variables
    ... it's an array of chars and, in function formal arguments, arrays can ... be substituted by pointers. ... global var ... extern int *var ...
    (comp.lang.asm.x86)
  • Re: why do the following crash
    ... extern int *arr; ... Try extern int arrin File2.c. ... Arrays and pointers aren't supposed to be interchangable. ...
    (comp.lang.c)
  • [PATCH] anobjrmap 2/6 linux/rmap.h
    ... declarations unrelated to locking, then the rest of the rmap ... * Locking primitives for exclusive access to a page's reverse-mapping ... +struct pte_chain * fastcall ... extern int shrink_all_memory; ...
    (Linux-Kernel)
  • Re: access violation in int array
    ... I have tested that when changing from extern int* p_int to extern int ... pointers are the same thing, which unfortunately the linker does not catch. ... Arrays and Pointers ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Why cant a public member function see a private data?
    ... 'private' has nothing to do with it. ... C++ uses declarations and definitions. ... The situation is similar to saying 'extern int q;', ...
    (comp.lang.cpp)