Go Down

Topic: Gobal Variable Value Persistence (Read 841 times) previous topic - next topic


I know this is elementary, but I've looked in my C programming books and can't find the answer.
Global Variables declared with a value.
I assume that unlike function local variables, which are not retained and re-initialized between calls, global variables that have values updated inside a function retain that value the next time the function is called, that is, until the variable is assigned a new value.

Is that true?




Just to add some more info, you can add static in front of variables in functions and they will persist between calls whilst still retaining the function-only scope.
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com

Go Up