(Ubuntu 18.04, gcc version 7.5.0)
I don't understand why individual sleep(); calls produce the desired pause in program processing. When I put sleep(); inside a for() loop, it seems all the iterations of for() happen at once (at the terminal output). One would think sleep() behaves the same inside or outside of a loop structure.
Also, during execution, when the for() loop is entered, my normally-flashing terminal cursor STOPS FLASHING. Is my system posessed? Thx.
Code:
#include <stdio.h>
#include <unistd.h>
int main() {
int y;
printf("\nOne\n");
sleep(1);
printf("Two\n");
sleep(2);
printf("Three\n");
sleep(3);
for (y = 0; y < 10; y++) {
printf("%d ", y);
sleep(2);
}
printf("\n\nDone\n\n");
return(0);
}