I have a file1.c and file2.c. If I define a variable in file1.c, and assign a value to it, how can I access this variable from file2.c?
How should I declare the variable in file1.c and how to retrieve the value from file2.c?
I have a file1.c and file2.c. If I define a variable in file1.c, and assign a value to it, how can I access this variable from file2.c?
How should I declare the variable in file1.c and how to retrieve the value from file2.c?
A.c:
int a;
A.h:
extern int a;
That's how. But don't. It's a bad idea.