0

I have int a[] in one C file. Now in another .c file I have extern int *a .

I need to know what will be the behavior if I try to access variable a in second file and why? What all problems would occur?

Cœur
  • 37,241
  • 25
  • 195
  • 267

2 Answers2

2

Undefined behaviour. So anything might happen.

Oliver Charlesworth
  • 267,707
  • 33
  • 569
  • 680
0

If you include the file(declaration) twice or declared variable named a, then there may be error redefinition of a;

when i tried the above compiler shows error :

conflicting types for a;
//previous definition in other file...
Dineshkumar
  • 4,165
  • 5
  • 29
  • 43
  • @dinesh: I dnt think so bcoz extern keyword says that its a declaration not definition or say when we say extern, it means somewhere in other file variable has been define, so how come redefinition error? – vaibhav shukla Jun 01 '13 at 13:54