From the CString interface, clearly one should not assume that a CString is null-terminated. However, it seems that sometimes there is, in fact, a null character at the end of the string. Is it possible, in the Windows implementation, to create a CString that does not have a null character, so that reading one character past the end of the string is looking at a different heap object?
Yes, the CString is always null terminated.
The documentation states that the you can cast a CString to LPCTSTR, and LPCTSTR is a typedef to one of:
__nullterminated CONST WCHAR *
__nullterminated CONST CHAR *
depending on whether UNICODE is defined or not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With