C - \r does not work in printf() with nanosleep() -
i trying use '\r' character write on previous line; however, when used in conjunction nanosleep(), program not output until end. here code example:
int i; struct timespec t = {1, 0}; (i = 0; < 10; ++i) { nanosleep(&t, null); printf('\ri: %d', i); } this wait 10 seconds, , print out i: 9. show updates, not end. i'm not sure if line being flushed or something?
any , appreciated!
the console caching line until char \n (newline) appears. can use "fflush" explicitly write content screen. maybe there little impact on performance.
Comments
Post a Comment