G
gomathy
Can a static variable defined in a module be indirectly accessed in
another module.
File1.c
-------
static int i;
int* ptr;
int main()
{
ptr = &i;
fun();
}
File2.c
--------
extern int* ptr;
fun()
{
printf("value of i = %d",*ptr);
}
Can "i" which is defined in 1.c be accessed in 2.c.
NB:- GCC allows u to do this without any segmentation fault.Can
someone give me the reason.
another module.
File1.c
-------
static int i;
int* ptr;
int main()
{
ptr = &i;
fun();
}
File2.c
--------
extern int* ptr;
fun()
{
printf("value of i = %d",*ptr);
}
Can "i" which is defined in 1.c be accessed in 2.c.
NB:- GCC allows u to do this without any segmentation fault.Can
someone give me the reason.