Double null-terminated string

后端 未结 2 1872
野性不改
野性不改 2021-01-05 02:57

I need to format a string to be double null-terminated string in order to use SHFileOperation.

Interesting part is i found one of the following working, but not both

2条回答
  •  迷失自我
    2021-01-05 03:36

    The CString class itself has no problem with a string containing a null character. The problem comes with putting null characters into the string in the first place. The first example works because it is appending a single character, not a string - it accepts the character as is without checking to see if it's null. The second example tries appending a typical C string, which by definition ends at the first null character - you're effectively appending an empty string.

提交回复
热议问题