C ++拆分宽字符串 [英] C++ Split Wide Char String
本文介绍了C ++拆分宽字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图将一个WideChar字符串拆分为一个数组,这里是我这样做的方式:<>
I'm trying to split a WideChar String in to an array, Here is the way I'm doing this :<>
WCHAR* Message = _T("This is a sample text"):
wchar_t *pwc;
CStringArray Command;
pwc = wcstok(Message, L" ");
int Count = 0;
while (pwc != NULL) {
pwc = wcstok(NULL, L" ");
Command.Add(pwc);
Count++;
}
for (int i = 0 ; i <= Count ; i++)
{
AfxMessageBox(Command[i]);
}
问题是我在最终的结果数组中没有This br>
错误?
The problem is I do not have "This" in my final result array
Whats wrong ?
推荐答案
您需要将调用移动到 Command.Add 在循环中分配
之前
- 因为它表明你在进行第一个添加
。
You need to move the call to Command.Add
before the assignment to pwc
in the loop - as it stands you're moving on to the second token before doing your first Add
.
这篇关于C ++拆分宽字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文