Mail Archives: djgpp/1994/09/01/10:12:23
There is a bug in scanf() in version 1.11.m5. The following code shows
the problem:
#include <stdio.h>
main()
{
while(1)
{
int i,j;
j=scanf("%d",&i);
printf("i=%d; j=%d\n",i,j);
}
}
As long as the field scanned is a valid integer, things work as
expected. However, if an invalid integer is entered, e.g., a character,
scanf returns 0 and leaves i untouched (this is as expected). The
problem is that on the next loop scanf no longer reads the console. It
simply returns zero without reading any input.
David Ronis
- Raw text -