The bug is probably in the construction of str2. Can you show us that code?
Thanks Doug!
I am not sure why, but my single post to the "VC.ATL" group has been posted
here too...???
Anyhow, your question is a copy of the answer from that group:
> The bug is probably in the construction of str2. Can you show us that code?
Right on the mark! I had a transfer function that was doing a += into a
CString that ended up placing one extra NULL in the string. I would have
never guessed that CString would support additional NULLs in the data but
sure enough, the following has the output of incrementing the length even
though the string passed to lstrlen() returns 0 every time!
_____________________________________
CString str("");
TCHAR ch = '\0';
MessageBox(::GetActiveWindow(), "Length: " + CTekString(str.GetLength()) ,
"str.GetLength()", MB_OK);
MessageBox(::GetActiveWindow(), "Length: " + CTekString(lstrlen(str)) ,
"str.GetLength()", MB_OK);
str += ch;
MessageBox(::GetActiveWindow(), "Length: " + CTekString(str.GetLength()) ,
"str.GetLength()", MB_OK);
MessageBox(::GetActiveWindow(), "Length: " + CTekString(lstrlen(str)) ,
"str.GetLength()", MB_OK);
str += ch;
MessageBox(::GetActiveWindow(), "Length: " + CTekString(str.GetLength()) ,
"str.GetLength()", MB_OK);
MessageBox(::GetActiveWindow(), "Length: " + CTekString(lstrlen(str)) ,
"str.GetLength()", MB_OK);
________________________________________
Output:
0
0
1
0
2
0
___________________________________________________
Thank you profusely for the insight!!!
TonyM
"Igor Tandetnik" wrote:
> "TonyM" <Tony_Morris @at Teledyne .dot com> wrote in message
> news:E0C38338-0056-4D63-8181-8C46CCB6346B@microsoft.com
[quoted text clipped - 47 lines]
> complete program, where you set up the arguments and then invoke the
> operator.