printf and scanf in IBMC on IBM 3090

Doug Gwyn gwyn at smoke.brl.mil
Wed Feb 6 06:26:43 AEST 1991


In article <1991Feb4.234251.14836 at ms.uky.edu> ghot at s.ms.uky.edu (Allan Adler) writes:
>In order to get the program to work correctly, the line
>printf("Please type your name: ");
>has to be replaced by
>printf("Please type your name: \n");
>I would never have predicted this based on my previous experience with C
>and my readings. Can someone tell me if this behavior is consistent with
>the ANSI standard ?

It's not just IBM; many systems will line-buffer output to an interactive
device, and the C standard encourages this.  What you SHOULD have done is
to insert
	fflush(stdout);
before trying to read interactive input, to ensure that the previous
prompt has been flushed out where the user can see it.



More information about the Comp.lang.c mailing list