CString Concatenation question
-
Hi I am trying to concatenate a number of CString, problem is After the third it includes the NULL termination which delimits the string. Let me post the code b_command, prog_location, end_addr and casid2 are all of type CString
int starters = strtol(prog_location,&hold_ptr,16);
int enders = starters + progsize;
_itoa(enders,p = end_addr.GetBuffer(0),16);b_command = b_command + prog_location + "-" + end_addr + " " + casid2;
b_command, prog_location, end_addr, and casid2 are all strings After b_commnd = ..... the string containing end_addr has the NULL marker included in b_command making the data casid2 invisible I can see that casid2 is there after the NULL by looking in memory
-
Hi I am trying to concatenate a number of CString, problem is After the third it includes the NULL termination which delimits the string. Let me post the code b_command, prog_location, end_addr and casid2 are all of type CString
int starters = strtol(prog_location,&hold_ptr,16);
int enders = starters + progsize;
_itoa(enders,p = end_addr.GetBuffer(0),16);b_command = b_command + prog_location + "-" + end_addr + " " + casid2;
b_command, prog_location, end_addr, and casid2 are all strings After b_commnd = ..... the string containing end_addr has the NULL marker included in b_command making the data casid2 invisible I can see that casid2 is there after the NULL by looking in memory
You must call
ReleaseBuffer()
after changing the string. While not doing so theCString
object may be in an undefined state. See CSimpleStringT::GetBuffer[^]:Quote:
If you use the pointer returned by GetBuffer to change the string contents, you must call ReleaseBuffer before you use any other CSimpleStringT member methods.
So use:
_itoa(enders,p = end_addr.GetBuffer(0),16);
end_addr.ReleaseBuffer(); -
You must call
ReleaseBuffer()
after changing the string. While not doing so theCString
object may be in an undefined state. See CSimpleStringT::GetBuffer[^]:Quote:
If you use the pointer returned by GetBuffer to change the string contents, you must call ReleaseBuffer before you use any other CSimpleStringT member methods.
So use:
_itoa(enders,p = end_addr.GetBuffer(0),16);
end_addr.ReleaseBuffer(); -
You must call
ReleaseBuffer()
after changing the string. While not doing so theCString
object may be in an undefined state. See CSimpleStringT::GetBuffer[^]:Quote:
If you use the pointer returned by GetBuffer to change the string contents, you must call ReleaseBuffer before you use any other CSimpleStringT member methods.
So use:
_itoa(enders,p = end_addr.GetBuffer(0),16);
end_addr.ReleaseBuffer();:thumbsup: