I have the following code. When I try to delete the pDest, error occurs. How can I delete pDest. Is there any other operation need to delete this?
{
int nReqLen = nSrcLength;
char* pDest = new char[nReqLen+1];
.
.
.
.
memcpy( (char*)pSource, pDest, nSrcLength );
delete pDest;
return nReturn;
}
You need to say
delete[] pDest. It was allocated as an array so it needs to be deleted as an array.