Quote Originally Posted by Salem View Post
Because your function prototype on line 2 of main.c is extern by default.
I have declared variable x in main.c file. I want to access this variable in another file FileA.c. That's why i used extern storage class

Code:
#include <stdio.h> 
  extern int x;  

int main ()

{
     x = 1;

    fun (x);

    return 0;
}
FileA.c
Code:
 

  #include <stdio.h>
  
 void fun ( )
  {
	  x++;
	  
	  printf ("x = %d \n", x);
	  
  }
I don't know why compiler show error error: 'x' undeclared (first use in this function)