开发者

How can you remove the last character from a wchar_t*?

开发者 https://www.devze.com 2022-12-13 20:14 出处:网络
How can I delete the last character of a wchar_t* and resize accordingly?For example, having the string \"test\" and bringing it开发者_JS百科 down to \"tes\"How about str[wcslen(str) - 1] = \'\\0\'

How can I delete the last character of a wchar_t* and resize accordingly? For example, having the string "test" and bringing it开发者_JS百科 down to "tes"


How about str[wcslen(str) - 1] = '\0'

Make sure the string is at least 1 character long first though!


Would you please explain what you mean by "resize accordingly"? Do you want to resize the buffer that was allocated? (Even if you think you do, you probably don't, because resizing to shave one character will probably throw the memory allocator off, but I think I should ask anyway)

0

精彩评论

暂无评论...
验证码 换一张
取 消