If I want to use variable in main function that is declare in another function so How to do that, for example x is declare in function foo but I want to use it in main function so I am making it extern but when I did it show the error
How to use variable in main function that is declare in other function ?
Code:#include<stdio.h>
void foo ()
{
extern int x = 2;
}
int main()
{
x++;
printf( "x = %d", x);
return 0;
}