Thats fine if you test with a finite for loop. but why is it first printing set of hello-err ? should it not print hello-out and then hello-err?
#include <stdio.h>
#include <unistd.h>
int main()
{
for(int i=0;i<5;i++)
{
fprintf(stdout,"hello-out");
fprintf(stderr,"hello-err");
// sleep(1);
}
return 0;
}

output: hello-errhello-errhello-errhello-errhello-errhello-outhello-outhello-outhello-outhello-out
expected (??) : hello-out hello-err hello-out hello-err hello-out hello-err hello-out hello-err hello-out hello-err
Just wanted to understand how the streams are interpreted by the compilers.