Doesn't ANSI C allow printing each character at a same place after a fixed time period?
问题 I am trying to generate random numbers to be printed on the console. I am programming in C on Linux. I wanted to print all the numbers at a single place after a time interval of a second for each number. I am using sleep() for stopping a 'time interval'. I tried \b , \r and all but none works. I just wanted this to run, for example : for (i = 0; i < 10; i++) { printf("%d", i); sleep(1); printf("\b"); } 回答1: stdout is probably buffered, so flush it. for(i=0;i<10;i++) { printf("%d",i); fflush