It's normal, standard output is buffered, but standard error output isn't.
For error outputs use stderr streams.
But if you want to use normal output, you should always invoke
fflush(FILE*)
for example:
Code:
#include <stdio.h>
int main (int argc, char **argv)
{
int i=0;
printf("%d", i);
fflush(stdout);
sleep(5);
i++;
printf("%d", i);
return 0;
}