Does anyone know why, if I put printf just before the delay, it waits until the delay ends before it displays a message?
Code1 with a dream ():
int main (void) { printf ("hi world"); system("sleep 3"); }
Code2 with delayed startup:
void delay(float sec) { time_t start; time_t current; time(&start); do{ time(¤t); }while(difftime(current,start) < sec); } int main (void) { printf ("hi world"); delay(3); }
And if:
printf ("hi world"); delay(3); printf ("hi world"); delay(3);
he waits until the amount is asleep, and then he will print messages at the same time.
Why is this happening?
UPDATE: I caused the delay ("sleep 3"), when I called the delay, I meant the delay (3). Fixed
source share