I need to share a variable's value which is modified in one program to reflect in another program..So I did the following.
Created a header file :
/* file1.h */ extern int a = 0;
created a C file:
/* file2.c */ #include"file1.h" #include<stdio.h> int main() { a = 15; printf("%d",a); return 0; }
created another C file:
/* file3.c */ #include"file1.h" #include<stdio.h> int main() { printf("%d",a); return 0; }
I wanted the file3.c
program to print the value 15 but it gave the output as 0.
How do I get the value in file3.c
program also?