CString
每当有"\t"
(制表符空格)字符时,我都会尝试将其一分为二。这是我正在使用的代码:
CString val = data->str;
CString valTok;
CString accTok;
int indx = 0;
valTok = val.Tokenize(_T("\t"), indx);
++indx;
accTok = val.Tokenize(_T("\t"), indx);
它很棒,但accTok
缺少第一个字符。例如,when val = "String1\tString2"
, valTok = "String1"
but accTok ="tring2"
... 怎么会?
编辑:
所以按照 hvd 的建议,我删除了indx
增量,我有以下代码:
CString val = ((CItemData*)lpDrawItemStruct->itemData)->str; // Was this value causing the problem in the end
CString valTok;
CString accTok;
int indx = 0;
valTok = val.Tokenize(_T("\t"), indx);
accTok = val.Tokenize(_T("\t"), indx); // ASSERT(iStart >= 0) fails
但是现在由于某种原因第一个Tokenize
返回..!-1
有任何想法吗?
解决了:
问题在于传递给的值val
:
((CItemData*)lpDrawItemStruct->itemData)->str
有时,在某些情况下第二次NULL
调用时会导致断言。Tokenize