www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/03/20/14:26:08

From: "Oliver Aspelin" <oliver AT aspelin DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: bug with ifstream?
Date: Sat, 20 Mar 1999 17:44:37 +0100
Organization: Regional Computing Center, University of Cologne
Lines: 29
Message-ID: <7d0ja0$rsb@news.rrz.Uni-Koeln.DE>
NNTP-Posting-Host: ra-uni2-c52-nc.rrz.uni-koeln.de
X-Newsreader: Microsoft Outlook Express 4.72.2106.4
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi,

I'm using the following bit of code:

ifstream data("words.dat");
while (!data.eof())
{
 string s;
 data >> s;
 if (s.length() > 0)
 {
  //...
 }
}

This works fine on a computer where it was compiled (= where djgpp is
installed), but not on other computers. It seems, like
data >> s doesn't do what I expect it to do (and what it does on the
computer where it was compiled). It should read a string from the file
linked to the data variable and proceed to the next line. When running on a
machine without djgpp it doesn't read nor proceed so it'll never stop as
data.eof() is never true.

Does anybody know this error/bug? What do I do wrong and how can I correct
it?

Greetings, Oliver


- Raw text -


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