mattKnight
Programmer
Code:
// mpszUser is a private class member of type LPCTSTR
void CXMLInfo::put_User(BSTR szUser)
{
_bstr_t bstrTemp(szUser);
mpszUser = new TCHAR[bstrTemp.length()];
_stprintf(const_cast<LPTSTR>(mpszUser), _T("%s"),(LPCTSTR)bstrTemp);
}
The above code is part of a class I am using to store information (extracted from an XML file as it happens).
When I am finished using the class, I need to free the memory used by the TCHAR array so I use the following in the destructor
Code:
if(mpszUser != NULL)
delete const_cast<LPTSTR>(mpszUser);
[code]
However, whenever this gets called my debug screen shows
[quote]
memory check error at 0x009726D6 = 0x00, should be 0xFD.
[/quote]
Can anyone tell me why? I have tried using the array version of delete (i.e. delete []) which I understand is what i should be using, but there is now difference.
Take Care
Matt
If at first you don't succeed, skydiving is not for you.