This is the mail archive of the cygwin@cygwin.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]

fscanf does not return EOF


Hi,

I am new to Cygwin and I am trying to port a code that is succesfully 
running with the HP-UX-C-compiler and the Linux-gcc.
I installed cygwin two days ago, and found it very helpful so far. I try to 
use the gcc version gcc-2.95.2-9 19991024 (cygwin experimental)
to compile my code.

It seems that fscanf() used on a text-file-pointer does not return an EOF when
reaching the end of the file. Instead fscanf returns 0. This is not very 
helpful, as an empty line would return the same value. The effect to my 
program is that it ends up looping endlessly in while().

Here a part of the code that presents the problem. I attempt to read the 
text file line by line in the while loop, and to stop the reading at EOF. 
My HP and Linux code has the fscanf format instruction slightly different: 
" %[^\n]".

char linetxt[BUFSIZ];
infile = fopen(polyfilename, "r");
if (infile == (FILE *) NULL) {
{
....
}

while (fscanf(infile," %[^\r]",linetxt)!=EOF)
{
...
}

Has anyone seen this behaviour, or am I doing something wrong?

Thanks a lot for the help.

Uwe



---------------------------------------------------------

Dr. ir. U. Pahner
Katholieke Universiteit Leuven
Dept. Elektrotechniek              UUU   UUPPPPPP
ESAT/ELEN                          UUU   UUPPPPPPP
Kasteelpark Arenberg 10           UUU   UUP   PPP
B-3001 Leuven-Heverlee/Belgium    UUU   UUPPPPPPP
                                    UUU   UUPPPPPP
Tel: +32-16-32.10.24 or 10.20      UUU   UUP
Fax: +32-16-32.19.85               UUU   UUP
                                    UUUUUUUUP
                                     UUUUUUU

ELEN on Internet:

http://www.esat.kuleuven.ac.be/elen/elen.html

---------------------------------------------------------


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple


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