How to tackle a debug assertion failure?
My application during run causes a debug assertion failed with an expression _BLOCK-TYPE_IS_VALID(pHead->nBlockUse) in the file dbgheap.c (line 1017).
I understand that the problem is related to some kind of memory allocation and nothing much beyond this. I am writing and reading structs to/from files created in the program. The application reads from the created file but then gives the aforementioned error message.
First in the class Change_setting (derived from CDialog) I have written a file by the name "Group". For writting the file I am using a structure type.
Then in another class (of the same project)CLPDATADlg(again derived from CDialog) I try to read the file with the same structure. But after reading the file it gives the above error:
Below is the code for writting and reading files.
void Change_Setting::OnUpdateConfig()
{
struct Configuration
{
int portAdd;
CString TimerClk;
};
struct Configuration Config1;
CString str4;
fstream file("GROUP", ios::out|ios::in);
if (!file){
MessageBox("Cannot Open
File","Error",MB_OK);
}
m_BaseAdd.GetWindowText(str4);
char *end;
Config1.portAdd = strtol(str4,&end,16);
Config1.TimerClk = strin7;
file.write((char*)&Config1,sizeof(Config1));
file.close();
}
void CLPDATADlg::RUN()
{
struct Configuration1
{
int portAdd;
CString TimerClk;
};
struct Configuration1 Config2;
char str2[25],strin10[25];
CString strg2,strg4,strg6,strg8;
fstream in("GROUP", ios::in|ios::binary);
if (!in){
MessageBox("Cannot Open
File","Error",MB_OK);
return;
}
in.read((char*)&Config2,sizeof(Config2));
portA = Config2.portAdd;
in.close();
}
Please help me.....I am very badly stuck.
Regards,
Juhi