raj_rohit10
Advanced Member level 4
The below given code prints only hello-err for some times then in bulk it prints hello-out...
what is the reason behind this?If i am adding \n in fprintf then it works fine...
#include <stdio.h>
#include <unistd.h>
int main()
{
while(1)
{
fprintf(stdout,"hello-out");
fprintf(stderr,"hello-err");
sleep(1);
}
return 0;
}
output of this code is On Solaris-Sparc Machine : hello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-
errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-
errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-
errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-
errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-
errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-
errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-
errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-
errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-
errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-
errhello-errhello-errhello-errhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-
outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-
outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-
outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-
outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-
outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-
outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-
outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-
outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-
outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-
outhello-outhello-out
While as per c it should be :hello-outhello-errhello-outhello-errhello-outhello-errhello-outhello-err...
for reply thanks in advance
rohit raj
what is the reason behind this?If i am adding \n in fprintf then it works fine...
#include <stdio.h>
#include <unistd.h>
int main()
{
while(1)
{
fprintf(stdout,"hello-out");
fprintf(stderr,"hello-err");
sleep(1);
}
return 0;
}
output of this code is On Solaris-Sparc Machine : hello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-
errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-
errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-
errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-
errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-
errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-
errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-
errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-
errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-
errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-
errhello-errhello-errhello-errhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-
outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-
outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-
outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-
outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-
outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-
outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-
outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-
outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-
outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-outhello-
outhello-outhello-out
While as per c it should be :hello-outhello-errhello-outhello-errhello-outhello-errhello-outhello-err...
for reply thanks in advance
rohit raj