Mail Archives: djgpp/1998/12/09/10:55:45
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 -