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

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -