Thanks for your reply.
dataRead.Left( 14 ); as you suggested.
I'm still getting memory leaks on serveral CString assigments. For
document.
I get a memory leak.
<lich...@gmail.com> ha scritto nel messaggionews:1191531287.053569.92960@50g2000hsm.googlegroups.com...
Hello, I'm writing an app using VS2005. I'm getting a memory leak in
the following code.
//-----------------------------
//Get the data back (16 bytes)
CString dataRead = CReader.GetData();
Is the content of "dataRead" correct for you?
( What is CReader.GetData() ? )
int i = 0;
char docArray[15];
//Take the first 14 bytes out
for(i=0; i<14; i++)
{
docArray[i] = dataRead[i];
}
docArray[14] = '\0';
docArray is a vector of chars. Strings are Unicode by default in VS2005...
So dataRead[i] should be a wchar_t... Don't you have any warning in this
code?
Are you compiling in ANSI (multibyte) mode?
Could you try to use CStringA instead of CString?
memset(docArray, 0, 0);
What is the purpose of the above memset?
It seems uncorrect to me...
I would prefer something like:
::ZeroMemory( docArray, sizeof( docArray ) );
However, I would prefer using a robust container like std::vector instead
raw arrays...
Moreover, if your purpose is to extract the first N characters from dataRead
string, you can use e.g. CString.Left, like this:
CString substring = dataRead.Left( 14 );
Giovanni