Interview Questions

In C, what is the difference between a static variable and global variable?

C Interview Questions and Answers


(Continued from previous question...)

In C, what is the difference between a static variable and global variable?

A static variable declared outside of any function is accessible only to all the functions defined in the same file (as the static variable). However, a global variable can be accessed by any function (including the ones from different files).

(Continued on next question...)

Other Interview Questions