delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/11/29/22:34:15

Xref: news-dnh.mv.net comp.os.msdos.djgpp:3501
Path: news-dnh.mv.net!mv!news.sprintlink.net!datalytics!news.ahc.ameritech.com!ddsw1!news.mcs.net!news.kei.com!newsfeed.internetmci.com!EU.net!peer-news.britain.eu.net!warwick!niss!bath.ac.uk!dcl-cs!strath-cs!st-and!Aberdeen!usenet
From: Iain N C Russell <russell>
Newsgroups: comp.os.msdos.djgpp
Subject: Dodgy fgets in DJGPP? Help!
Date: 28 Nov 1995 11:22:49 GMT
Organization: University of Aberdeen, Scotland
Lines: 31
Nntp-Posting-Host: pelican.csd.abdn.ac.uk
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Dj-Gateway: from newsgroup comp.os.msdos.djgpp

Hi, 

I've started using DJGPP V2 to compile the database-type program
I'm writing and have come across a strange problem that does not
occur when I compile with BC3.1...

I have 3 similar routines for reading different types of files, all
using a basic
  while(!feof(fp)) {
    fgets(line, MAX_CHARS, fp);
    /* other code here, none of it altering fp */
  }

loop.

The thing is, one routine works fine.

The second reads the first line, but then fp becomes 0 for some
unknown reason. According to ferror(fp) there is no problem with fp, though
this may be because it has become 0 by the time it is checked....The
consequence is that is gets into an infinite loop, trying to read a line from a
NULL stream.

The third routine reads lines until the last one then does the same as above.

Since the routines work fine under Borland, is there some known problem with
fgets in DJGPP or does it just behave slightly differently for some reason?

Thnaks for any help, 
Iain

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019