A
aruna.mysore
Hi all,
I have specific question about usage of extern. I want to share a
single variable say int a; across multiple files.
I would define it in file1.c as
int a=0;
int main()
{
.........
a= 20;
..........
}
In another file2.c I would use it as,
int main()
{
extern int a;
................
printf("value of a=%d\n", a);
..................
}
Is this usage right. If yes, how do I run these as two separate
processes so that value changed in file1 is always reflected in file2
whenever it is used in fil2.c. How do I link these two processes put
it in another way.
Regards,
Aruna
I have specific question about usage of extern. I want to share a
single variable say int a; across multiple files.
I would define it in file1.c as
int a=0;
int main()
{
.........
a= 20;
..........
}
In another file2.c I would use it as,
int main()
{
extern int a;
................
printf("value of a=%d\n", a);
..................
}
Is this usage right. If yes, how do I run these as two separate
processes so that value changed in file1 is always reflected in file2
whenever it is used in fil2.c. How do I link these two processes put
it in another way.
Regards,
Aruna