CString split
以下默认采用逗号分隔,并转换成数组
int GetStringValues(CString svalue, unsigned long *values, int limit)
{
CString stemp;
int index = 0;
if (svalue.IsEmpty() || limit == 0)
{
return 0;
}
int pos = 0;
int pre_pos = 0;
while(pos >= 0 && index < limit){
pos = svalue.Find(_T(","),pre_pos);
if (pos < 0)
{
values[index++] = _ttol(svalue.Mid(pre_pos));
break;
}
values[index++] = _ttol(svalue.Mid(pre_pos, pos-pre_pos));
pre_pos = pos+1;
}
return index;
}
本文介绍了一种使用CString进行字符串拆分的方法,并将其转换为整数数组。此方法适用于需要从逗号分隔的字符串中提取数值的应用场景。
955

被折叠的 条评论
为什么被折叠?



