delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/12/25/07:46:02

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: "Cody" <cody1 AT ktsnet DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: bug in djgpp 3.0.2? surely it's my fault
Lines: 30
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
X-Original-NNTP-Posting-Host: kx-nachtx-ppp044.ktsnet.com
Message-ID: <3c24f3be@leia.ktsnet.com>
Date: Sat, 22 Dec 2001 14:47:36 -0600
NNTP-Posting-Host: 216.60.177.225
X-Complaints-To: abuse AT swbell DOT net
X-Trace: nnrp2.sbc.net 1009054037 216.60.177.225 (Sat, 22 Dec 2001 14:47:17 CST)
NNTP-Posting-Date: Sat, 22 Dec 2001 14:47:17 CST
Organization: SBC Internet Services
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I'm having difficulty understanding why the following gives an infinite loop
on djgpp 3.0.2 but not on prev. versions nor on TC++ 3.0:

#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;

int get_key();//problematic function

int main() {
cout<<get_key()<<endl;
return EXIT_SUCCESS;
}

int get_key() {
ifstream input("con");//of course "con" is non-standard, but it's still a
"file", so there should be no problem
return input.get();//get() creates infinite loop (well, not inf. loop, but
it waits until I press EOF [Cntr+Z]).
//get() is supposed to return next key, not return next key only after EOF
has been pressed.
}
//What am I doing wrong?

--
__________________________________
Microsoft spel chekar vor sail, worgs grate!


- Raw text -


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