extern variable tell to compiler about scope
I've declare variable x in file1.c
file1.c
I want use the variable x in main.c fileCode:extern int x;
main.c
Code:#include<stdio.h>
int main(void)
{
x = 10;
printf("x=%d ", x);
return 0;
}
when i compile code I get error: 'x' undeclared (first use in this function)
What's wrong in code ? How can I use variable in main.c that is declarered in another file