1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
#include "stdafx.h"
#include "test_mfc.h"
#include "test_mfcDlg.h"
#include "afxdialogex.h"
#include "a.h"
# include <fstream>
class Client
{
public:
Client(CString Name , CString LastName , CString Id , bool HasCheckingAcc = false , bool HasSavingAcc = false );
int create();
CString name;
CString lastName;
CString id;
bool hasCheckingAcc;
bool hasSavingAcc;
};
Client::Client(CString Name , CString LastName , CString Id , bool HasCheckingAcc , bool HasSavingAcc )
{
name = Name;
lastName=LastName;
id=Id;
hasCheckingAcc=HasCheckingAcc;
hasSavingAcc=HasSavingAcc;
}
void displayMessage(CString message , CString title=L"Meesage")
{
MessageBox(NULL,message,title,MB_OK | MB_ICONERROR);
}
//some other parts ...
void Ctest_mfcDlg::OnBnClickedButton2()
{
Client myCl(L"Name",L"D",L"11111");
Client myCl2(L"N2",L"D2",L"22222");
wofstream output;
output.open("12345566.test" , ios::binary);
if( output.fail() )
{
CString mess;
mess = strerror( errno );
displayMessage(mess);
}
output.write( (wchar_t *) &myCl , sizeof(myCl));
output.close();
wifstream input;
input.open("12345566.test" , ios::binary );
if(! input.fail())
{
input.read( (wchar_t *) &myCl2 , sizeof(myCl2));
CString mess;
mess.Format(L"Name:%s\nID:%s",myCl2.name,myCl2.id );
displayMessage(mess);
}
else
{
CString mess;
mess = strerror( errno );
displayMessage(mess);
}
}
|