Mail Archives: djgpp-workers/1998/08/27/09:18:39
Dear colleagues,
Please excuse me. There was a mistake in that program:
#include<stdio.h>
main()
{
int a, b, c;
char d;
scanf("%d%d", &a, &b);
scanf("%c", &d);
if (d=='y') c=a*b;
/* ^
\_ in original was 'c'
*/
else c=a+b;
printf("\n%d\n", c);
}
Thanks to George Foot by let me see this!
The (reformulated) problem is: what could be the best way to clean
the buffer (Nate Eldredge told me that "ANSI says that the effect of
fflush'ing an input stream is undefined") to the second scanf call
doesn't read next character typed just after the second number, if
it is newline?
Excuse me my mistakes and thank you in advance!
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
- Raw text -