Weird outputs in file
int main()
{
ofstream outCredit( "credit.txt" , ios::out | ios::binary ) ;
if( !outCredit )
{
cerr << "File could not open file " << endl ;
exit(1) ;
}
ClientData blankClient ;
for( int i = 0 ; i < 100 ; ++i )
outCredit.write( reinterpret_cast< const char* >( &blankClient ),
sizeof( ClientData ) ) ;
}
I have declared a ClientData class with members namely int account , char
firstName[15] , char lastName[10] , double account ? When the file is
created , which should contain 100 empty records , I am getting something
like this in the entire file 100 times , what is wrong here ?
No comments:
Post a Comment