I am coding an application in C. One of the screens has a cursor. The cursor needs to keep blinking. I have a infinite while loop that keeps refreshing the screen. To get the effect of blinking, at every fifth iteration of this while loop, the cursor needs to alternate between appear and disappear.
I need to somehow keep a count of the iteration. I can declare a variable outside the while loop that can do the counting, but feel that this is inelegant because I have a drawCursor() function that updates the state of the cursor and this needs to take care of it without me having to declare this variable outside the while loop.
Is there a way to do it without having this count integer? What is an elegant way to accomplish this cursor blinking effect?
Simply have a
staticvariable inside the function.