www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/07/11:00:34

Newsgroups: comp.os.msdos.djgpp
From: "A. Jans-Beken" <jabe AT oce DOT nl>
Subject: Allegro -> possible bug
Message-ID: <34B39B82.4D55@oce.nl>
Sender: news AT oce DOT nl (The Daily News @ nntp01.oce.nl)
Organization: Océ-Nederland B.V.
Mime-Version: 1.0
Date: Wed, 7 Jan 1998 15:13:06 GMT
Lines: 33
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I have noticed a difference between the allegro 2.2 function:
   pack_fgets(...)
and the standard stdio function:
   fgets(...)

It seems that the standard function reads a string INCLUDING the '\n' at
the end while the packed function reads a string WITHOUT the trailing
'\n'.

In stdio code this means:
int main() {
   ...
   fputs("hello\n", f);
   ...
   fgets(buffer,100,f);
   *(buffer + strlen(buffer) - 1) = '\0';
   ...
   }

versus the allegro code:
int main() {
   ...
   pack_fputs("hello\n", f);
   ...
   pack_fgets(buffer,100,f);
   // String is already terminated by '\0'
   ...
   }

Dono if this is the same in version 3.

greetings,
Twan Jans-Beken

- Raw text -


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