-
updating during loops
Im trying to print some characters on a timed loop(using GetTickCount), and i want 1 to be printed every 10 ms. But the problem is that it prints a bunch of characters over an interval larger than 10 ms. It seems not to be updating at each loop. Is there like a DoEvents statement, like in VB?
thanks
-
That's buffering, and there's an easy way to fix it. Are you using C or C++?
-
You force the buffer to flush after you place something in it.
Otherwise the character(s) stay parked in the buffer, and get put to the screen in big blobs.
In C you can use fflush() --
Code:
putc(ch,stdout);
fflush(stdout);
-
Or for C++, use cout << flush;