In the following code you are trying to copy from the structure
oModel
to
Buff
, but that pointer has not been initialised so you will corrupt some memory or cause a memory access error.
char *Buff;
oModel = new SModelInfo;
pCustInfoFile->Read(oModel,sizeof(SModelInfo));
strncpy(Buff,(char*)&oModel,sizeof(SModelInfo));
It should read
char *Buff;
oModel = new SModelInfo;
pCustInfoFile->Read(oModel,sizeof(SModelInfo));
Buff = new char[sizeof(SModelInfo)]; strncpy(Buff,(char*)oModel,sizeof(SModelInfo));
In the following code you create a pointer, initialise it with
new
and then immediately overwrite it with a different pointer thus losing the previously allocated block.
SModelInfo *oModel1;
oModel1 = new SModelInfo;
oModel1 = (SModelInfo*)buff;
This should be
SModelInfo *oModel1 = (SModelInfo*)buff;