What is the difference between the two files. file1.c# include...........int i;void main(){..........}file2.c# includestatic int i;void main(){....}

While in this case for both the programs... the scope and lifetime of variable 'i' is throughout the program..... the value of 'i' is not. For eg. if 'i=2' in the file1.c, any other program accessing this variable from outside will still see the value of i as 2. Whereas in File2.c if the variable 'i' is accessed from any other program its value will always be seen as 0

Reason: For static variables their values are active only within the COMPILE AREA of where it is declared or in the program where it is declared.

 

This Question is not yet answered!

 
 

Related Answered Questions

 

Related Open Questions