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");
}
stdout is probably buffered, so flush it.