Quote:
|
Originally Posted by amateurrobotguy
If I want to define a variable inside of a function and want it to be available to all functions in the .c file, will static do it?
|
No, not as you listed it. If you declare a variable inside a function (static or not), it is only available inside that function. The difference is that a static variable declared inside a function will retain its value between calls to that function. So it acts like a global variable but it can only be seen by that function.
If you need to access a variable from many functions you can either make it a global variable or pass it around as part of the function calls.