Newsgroups: comp.os.msdos.djgpp From: manni AT hotbot DOT com (Manni Heumann) Subject: Re: Problem with reading from file References: <366E8AF8 DOT 66A4549B AT ostenberg DOT ping DOT de> X-Newsreader: News Xpress 2.01 Date: Wed, 09 Dec 1998 15:27:42 GMT NNTP-Posting-Host: dhcp33-242.uni-bielefeld.de Message-ID: <366e96ef.0@news.uni-bielefeld.de> X-Trace: 9 Dec 1998 16:27:43 +0200, dhcp33-242.uni-bielefeld.de Lines: 51 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com In article <366E8AF8 DOT 66A4549B AT ostenberg DOT ping DOT de>, Klaus Petzold wrote: >Hi, > >I am using gcc 2.7.2.1 and try to do >the following: > >#include >#include >#include > >int main() >{ > ifstream Quelle; > > Quelle.open("test.dat", ios::binary); > if (!Quelle) > { > cout << "File not found."; > exit(-1); > } > > char ch; > while (Quelle.read((char *)&ch, sizeof(ch))) > cout << ch; >} > >Test.dat exists and is 10 bytes large, but the program >doesn't enter the while-loop. Any ideas why it doesn't work? > >Klaus > > Yes! Try Quelle.open("test.dat", ios::binary | ios::in); instead of Quelle.open("test.dat", ios::binary); ----------------------------------------------------------- Manni Heumann Bielefeld, Germany Spammers use reply-adress, all others: mheumann AT post DOT uni-bielefeld DOT de -----------------------------------------------------------