#include <stdio.h>
  #include <unistd.h>
  int main()
  {
          while(1)
          {
                  fprintf(stdout,"hello-out");
                  fprintf(stderr,"hello-err");
                  sleep(1);
          }
          return 0;
  }

why is that i am getting heelo-err instead of hello-out

>no it doesnt ..
Did you use it correctly?

fprintf(stdout,"hello-out");
fflush(stdout);
fprintf(stderr,"hello-err");

stdout is buffered by default while stderr is not. The three ways to flush a buffered stream are filling it up ("hello-out" is unlikely to do that), printing a newline (which you don't), and calling fflush.

flushall isn't guaranteed to be available as it's a non-standard extension. Besides, you can achieve the same effect as flushall (assuming it does what one might expect) with fflush(NULL).

Edited 6 Years Ago by Narue: n/a

flushall isn't guaranteed to be available as it's a non-standard extension.
Besides, you can achieve the same effect as flushall (assuming it does what one might expect) with fflush(NULL).

Actually, it is and but I have experienced myself, somewhat inconsistent behaviour of C++ compilers where they give
inaccurate result on first compilation mostly one rebuilding in file operations in C.
So, I was just rebuilding the object file using a new function.
Just Thanks for refreshing my memory about that alternate and somewhat tricky function.
-Manoj

>Actually, it is
Prove it. I can prove otherwise by showing the lack of a definition for flushall in the C standard, so you're already in a hole.

>and but I have experienced myself, somewhat inconsistent behaviour of C++ compilers where they
>give inaccurate result on first compilation mostly one rebuilding in file operations in C.

While at a glance this (and all of your other posts) look like English, they're largely incomprehensible.

Comments
Indeed
This question has already been answered. Start a new discussion instead.