www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/08/01/14:30:42

Date: Tue, 1 Aug 1995 10:16:05 +0000 (GMT)
From: Torsten Schweigert <qiqd3 AT hobbit DOT chemie DOT uni-halle DOT de>
To: linux-gcc <linux-gcc AT vger DOT rutgers DOT edu>
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: How to read a file binary

Hi,

I have the following problem: When running this program

#include <fstream.h>

int main(void)
{
   unsigned char buff;
   ofstream WriteFile("test.out",ios::bin);
   ifstream ReadFile("test.in",ios::bin);

   while(!ReadFile.eof())
   {
      ReadFile.get(buff);
      WriteFile.put(buff);
      cout << buff;
   }

   return 0;
}

which simply should copy one file to another, it reads only on character 
and then exits. If I open the file in text mode all works well.

Anybody a hint what I'm doing wrong?

Torsten

- Raw text -


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