In a C-style string, the NULL character means "end of string". The
CString
object will display all characters untill the NULL character is found. But it doesn't mean the next characters are not stored or lost.
For example:
CString foo;
foo += 'a';
foo += 'b';
foo += '\0';
foo += 'c';
foo += 'd';
char c = foo[3];
char d = foo[4];
int l = foo.GetLength();
In the above code, the debugger will display
"ab"
for the foo variable, however,
c
will contain
'c'
and
d
will contain
'd'
as expected.
But if you want to store a block of memory somewhere, I suggest not to use
CString
class. Use a byte or char array instead (
CByteArray
for example, or regular arrays).