learning c

Andrew Koenig ark at alice.UUCP
Tue Apr 4 13:34:18 AEST 1989


In article <584 at greens.UUCP>, matthew at sunpix.UUCP ( Sun NCAA) writes:

>     I know your problem well.  What you are looking for is a 'getch()' or
> 'getche()' function in place of the 'getchar()' function.  Barring that try

> c = getchar();
> fflush(stdin);

Why depend so intimately on the detailed behavior of the
C run-time library?  Not all implementations support
fflush(stdin).  The following is much more portable:

	c = getchar();
	if (c != '\n')
		while (getchar() != '\n')
			;
-- 
				--Andrew Koenig
				  ark at europa.att.com



More information about the Comp.lang.c mailing list