delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/12/09/10:55:45

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 <Klaus AT ostenberg DOT ping DOT de> wrote:
>Hi,
>
>I am using gcc 2.7.2.1 and try to do
>the following:
>
>#include <iostream.h>
>#include <stdlib.h>
>#include <fstream.h>
>
>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
-----------------------------------------------------------

- Raw text -


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