Date: Wed, 26 Aug 1998 13:41:34 -0300 (EST) From: Carlos Eduardo Dantas de Menezes To: Nate Eldredge cc: dj AT delorie DOT com, djgpp-workers AT delorie DOT com, Vik DOT Heyndrickx AT rug DOT ac DOT be Subject: Re: In-Reply-To: <35CA4428.27B48B43@cartsys.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk Dear colleagues, Please help me with this problem: the following program should run correctly, and it runs in others compilers. But in DJGPP we had problems when our programs use scanf("%c", &x) mixed with scanf("%d", &y) or scanf("%f", &z), the first one is not runned sucessfully. I tried to use fflush(stdin), but, like Nate Eldredge told me, "ANSI says that the effect of fflush'ing an input stream is undefined", and this idea didn't work. What could be the correct way to use scanf safely? Thank you in advance. Carlos Menezes. #include main() { int a, b, c; char d; scanf("%d%d", &a, &b); scanf("%c", &d); if (c=='y') c=a*b; else c=a+b; printf("\n%d\n", c); } Carlos Menezes -- Tycho Brahe Project LABORATORIO DE SISTEMAS INTEGRAVEIS. ESCOLA POLITECNICA DA UNIVERSIDADE DE SAO PAULO. E-MAIL: menezes AT lsi DOT usp DOT br URL: http://www.lsi.usp.br/~menezes/menezes.html