Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Message-Id: <5.0.0.25.0.20010329081648.00a63b40@barbar.esat.kuleuven.ac.be> X-Sender: uwe AT barbar DOT esat DOT kuleuven DOT ac DOT be X-Mailer: QUALCOMM Windows Eudora Version 5.0 Date: Thu, 29 Mar 2001 08:20:14 +0200 To: cygwin AT cygwin DOT com From: Uwe Pahner Subject: fscanf does not return EOF Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed 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