Go Down

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

Zarkoff

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?

Thanks,
John

Arrch



marco_c

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 http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

Go Up