[Courses] Re: [C] A clarification on fflush(stderr)

Laurel Fan laurel at sdf.lonestar.org
Thu Aug 8 18:19:51 EST 2002


On Thu, Aug 08, 2002 at 08:40:33PM -0400, Christopher James Lahey wrote:
> On Thu, 2002-08-08 at 17:10, Laurel Fan wrote:
> > That's strange.  stderr on my system is unbuffered, unless there's
> > something wrong with this code:
> > 
> > #include <stdio.h>
> > 
> > int main()
> > {
> >    fprintf(stderr, "stderr is unbuffered");
> >    sleep(60);
> > }
> 
> Might it be line buffered?  What happens if you put a \n at the end of
> the string?

I'm pretty sure it's not line buffered.

It is unbuffered, which means it printed "stderr is unbuffered" right
away.  If it was line buffered, it would not print "stderr is
unbuffered" right away.

I imagine putting a \n at the end of the string would cause it to
print a newline.

-- 
laurel at sdf.lonestar.org
http://dreadnought.gorgorg.org



More information about the Courses mailing list