Hi there,

Code:
#include <iostream>
#include <fstream>
using std::cin;
using std::cout;
using std::ofstream;
using std::ifstream;
using std::fstream;
using std::ios;
using std::endl;

struct Books
{
char *BookName;
int Pages;
};

void write_binary(Books A);
void read_binary();

int main()
{
	Books A;
	A.BookName="C++";
	A.Pages=450;
	write_binary(A);
	return 0;
}

void write_binary(Books A)
{
    fstream binary_file("c:\\test.dat",ios::out|ios::binary|ios::app); 
    binary_file.write(reinterpret_cast<char *>(&A),sizeof(Books));
    binary_file.close();
}

void read_binary()
{
     Books B;
     fstream binary_file("c:\\test.dat",ios::binary|ios::in);
     binary_file.read(reinterpret_cast<char *>(&B),sizeof(Books));
     binary_file.close();

     cout<<"Book's name : "<<B.BookName<<endl;
     cout<<"Pages :"<< B.Pages<<endl;

}
Code:
int main()
{
	read_binary();
	return 0;
}
the result i have seen is
Book's name : C:\test.dat
Pages : 1

Why the result is not the same as i have assigned?

Thanks for advance