Loading
submit to reddit
May 18, 2013, 08:24:02 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome!
 
   Forum Home   Help Search Forum Login Register  
Pages: [1]   Go Down
  Send this topic  |  Print  
Author Topic: Problem in writing file in binary mode  (Read 606 times)
sheeraz_am
Newbie
*
Posts: 8


« on: August 15, 2009, 02:18:04 PM »

Hi,
    I am writing an object in a file using binary mode, in these two statements.
   
   fstream qfile(ios::out, ios::binary);
   qfile.write( reinterpret_cast<char*>(&qObject) , sizeof(qObject) );
   
   My Question is that:
                   Why it is necessary to type cast the object to  char* ? any reason.
                             
                                             Thanks
Logged
Michael Hall
Administrator
Hero Member
*****
Posts: 899



« Reply #1 on: August 15, 2009, 04:21:39 PM »

Well, the simple answer is a char* is what the function takes. Binary mode works that way. Everything a is just considered a sequence of bytes, unlike text mode.

Mike
Logged
sheeraz_am
Newbie
*
Posts: 8


« Reply #2 on: August 15, 2009, 05:42:06 PM »

Oh thanks
Logged
Pages: [1]   Go Up
  Send this topic  |  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!