Message-ID: <19980326011928.13219.qmail@www06.netaddress.usa.net> Date: Thu, 26 Mar 1998 01:19:28 From: Carl Kalauokalani To: djgpp AT delorie DOT com Subject: Binary streams... Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk Hi. I'm having a bit of trouble using binary streams via djgpp. The code below (which I borrowed from the Borland support site) serves to demonstrate the problem; with the MS or Borland compilers, the two files are created as expected (text.txt: 49 bytes, bin.txt: 47 bytes), but with DJ the bin.txt file is empty. Am I missing something? Any help most appreciated... Carl Kalauokalani ckalauokalani AT usa DOT net ================================================================== //*********************************************************** // Stream.cpp // // This is an example of using binary mode streams. // //*********************************************************** #include #include #include #include int main( void ) { ofstream ofilet ; ofstream ofileb ; float ff = 3.14159 ; ofilet.open( "text.txt" ) ; ofileb.open( "bin.txt", ios::binary ) ; // Write to text-mode file ofilet << "Float as String: " << ff << "\n" ; ofilet << "Float as Binary: " ; ofilet.write( (char *) &ff, sizeof( ff ) ) ; ofilet << "\n" ; // Write to binary-mode file ofileb << "Float as String: " << ff << "\n" ; ofileb << "Float as Binary: " ; ofileb.write( (char *) &ff, sizeof( ff ) ) ; ofileb << "\n" ; // Write to screen cout << "Float as String: " << ff << "\n" ; cout << "Float as Binary: " ; cout.write( (char *) &ff, sizeof( ff ) ) ; cout << "( Garbage Expected )\n" ; return 0 ; } // ***** end of stream.cpp ******************************** ____________________________________________________________________ Get free e-mail and a permanent address at http://www.netaddress.com