This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

scanf does not return EOF?


Hi,

Does anyone encounter this:

Upon end-of-file scanf seems return 0 instead of EOF (which is -1 in
gcc). The following is a simple test, your comments is appreciated.

#include <stdio.h>
main()
{
  int i;
  int end=0;
  int state, rectype, persons, hhtype;
  
  while(!end) {
  if ((i = scanf(" %d %d %d %d\n", &rectype,
                  &state,
                  &persons, &hhtype)) == EOF) 
    {
      printf("end of line reached\n");
      printf("%d\n",i);
      end=1;
    } else {
      printf("readin one line\n");
      printf("%d %d\n",i, EOF);
    }
  }
}

Input is this:
1 2 3 4
2 4 5 6

These are the steps:

gcc junk.c
a.exe <junk.dat
...

Tao Zuo
-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]