printf and scanf in IBMC on IBM 3090

Allan Adler ghot at s.ms.uky.edu
Tue Feb 5 10:42:51 AEST 1991


Perhaps someone can clear up a mystery. The enclosed program compiles
correctly using IBMC on an IBM3090. When I run it, it refuses to execute
the first printf until after the user has typed something in for the
scanf statement, whereupon it executes both printf statements.
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 ?

Allan Adler
ghot at ms.uky.edu
==========================================================================

#include <stdio.h>
main()
{
char name[20];
printf("Please type your name: ");
scanf("%s",name);
printf("You can do it, %s!\n",name);
}


Allan



More information about the Comp.lang.c mailing list