i have this simple code" printinterval in int
sleep(printinterval/3);
displayPrint(); //// just some printing func
sleep(printinterval/3);
displayPrint();
sleep(printinterval-2*(int)(printinterval/3));
displayPrint();
the problem is that it doest not do the delay the right way, jumps over 1 sleep
but
sleep(printinterval/3);
printf("\n");
displayPrint(); //// just some printing func
printf("\n");
sleep(printinterval/3);
printf("\n");
displayPrint();
printf("\n");
sleep(printinterval-2*(int)(printinterval/3));
printf("\n");
displayPrint();
works like a charm
any ideas? thx :)
EDITED: thx for the help found this way to fix it
fflush(stdout); // Will now print everything in the stdout buffer
and again, thx