Mail Archives: djgpp/1995/11/29/22:34:15

Xref: comp.os.msdos.djgpp:3501
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
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Dj-Gateway: from newsgroup comp.os.msdos.djgpp


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 */


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, 

- Raw text -

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