setlinebuf(stdin)

Chris Torek chris at mimsy.UUCP
Sun Aug 14 16:01:30 AEST 1988


In article <291 at quintus.UUCP> ok at quintus.uucp (Richard A. O'Keefe) writes:
>The remedy is simple.  Only your program needs to change.
>Before reading from stdin, do
>	setbuf(stdin, (char*)NULL);	/* all flavours */
>or	setlinebuf(stdin);		/* BSD */
>or use setvbuf in System V.

Setlinebuf() has no effect on input streams.  I imagine setvbuf will
not set line-at-a-time reading on SysV either.  Think about it:  how
will you tell the system to read only up through a newline?

Using setbuf(stdin, (char *)NULL) will do the trick, but is terribly
inefficient.  I prefer my fseek-before-exit suggestion . . . .
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.wizards mailing list