Hi EveryBody, I am again here with a petty issue................
Please Help me, I am a newly born programmer to MFC
To Write/Read structure on File, I wrote the following code.
Code:
/* test is a structure defined in stdafx.h*/
/*
struct test
{
CString name;
CString age;
};*/
Code:
void CFileOperationsDlg::OnBnClickedButton1()
{
this->UpdateData (TRUE);
CFile f;
CFileException Fexcep;
test buffWrite;
test buffRead;
buffWrite .age ="27";
buffWrite .name = "My Name";
f.Open ("E:\\MyFile.bcr", CFile ::modeCreate | CFile ::modeWrite ,&Fexcep);
f.Write (&buffWrite,sizeof(buffWrite ));
f.Close ();
if(f.Open("E:\\MyFile.bcr", CFile ::modeRead ,&Fexcep) == FALSE)
return;
try
{
f.Read (&buffRead ,sizeof(buffRead ));
}
catch(CException *e)
{
e->AssertValid ();
}
f.Close ();
}
The Following Exception occurs when the last statement in code executes.........
Unhandled exception at 0x7c176d3f (mfc71d.dll) in FileOperations.exe: 0xC0000005: Access violation reading location 0xfeeefeee.