#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

Try to use fflush() function.
May be that will solve your problem.
-Manoj

no it doesnt ..

>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.

use flushall() instead of that.

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).

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.

commented: Indeed +17
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.