vc的split函数怎么用? VB中有split能把字符串按照一定的符号分割成数组,VC里面的相应的函数是什么?我的字符串是m_Message="abc,def,ghi,klm"把它分割好放到数组str_N里面,听帮忙写一下代码,谢谢了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这是我自己写的,你可以参考,调用方法: String2Array(sInputFormat, m_arrType, ';');int String2Array(const CString& s, CStringArray &sa, char chSplitter){ int nLen=s.GetLength(), nLastPos, nPos; bool bContinue; sa.RemoveAll(); nLastPos=0; do { bContinue=false; nPos = s.Find(chSplitter, nLastPos); if (-1!=nPos) { sa.Add(s.Mid(nLastPos, nPos-nLastPos)); nLastPos=nPos+1; if (nLastPos != nLen) bContinue=true; } } while (bContinue); if (nLastPos != nLen) sa.Add(s.Mid(nLastPos, nLen-nLastPos)); return sa.GetSize();} 不会吧?VC没有相应的API吗?什么都要自己写,效率怎么提升呀? CString GetParam(CString& mName){ int P = mName.Find(","); char m_Res[256] =""; if (P != -1) { sprintf(m_Res, "%s", mName); m_Res[P] = '\0'; mName.Delete(0, P + 1); mName.TrimLeft(); mName.TrimRight(); } return m_Res;} 下面的也可以int SplitString(CString & str, TCHAR cTok, CStringArray& aryItem){ TCHAR* p = str.GetBuffer(0); TCHAR* e = p; TCHAR cEnd = *e; int nCount = 0; while(cEnd) { if(*e == _T('\0')) cEnd = *e; else if(*e == cTok) *e = _T('\0'); if(*e) e++; else { if(*p != _T('\0')) { aryItem.Add(p); nCount++; } p = ++e; } } return nCount;} BHO不起作用? CTime时间转换的问题 请问如何 动态改变 edit控件 Disabled 后的字体颜色???? 如何在office2000中使用ActiveX控件,UP有分 最简单的win API程序,大家帮我看看 提问:我写的程序A去调别人的程序B,遇到的问题,2天了都没找到原因,请求帮助! 关于关键字重复的问题 高薪聘请"COM高手"作顾问 怎样填充对话框背景(API函数)? putcollect出错 求助一个关于函数调用的问题 回调函数怎么实现
String2Array(sInputFormat, m_arrType, ';');int String2Array(const CString& s, CStringArray &sa, char chSplitter)
{
int nLen=s.GetLength(), nLastPos, nPos;
bool bContinue;
sa.RemoveAll();
nLastPos=0;
do
{
bContinue=false;
nPos = s.Find(chSplitter, nLastPos);
if (-1!=nPos)
{
sa.Add(s.Mid(nLastPos, nPos-nLastPos));
nLastPos=nPos+1;
if (nLastPos != nLen) bContinue=true;
}
} while (bContinue);
if (nLastPos != nLen)
sa.Add(s.Mid(nLastPos, nLen-nLastPos));
return sa.GetSize();
}
{
int P = mName.Find(",");
char m_Res[256] ="";
if (P != -1)
{
sprintf(m_Res, "%s", mName);
m_Res[P] = '\0';
mName.Delete(0, P + 1);
mName.TrimLeft();
mName.TrimRight();
}
return m_Res;
}
int SplitString(CString & str, TCHAR cTok, CStringArray& aryItem)
{
TCHAR* p = str.GetBuffer(0);
TCHAR* e = p;
TCHAR cEnd = *e;
int nCount = 0;
while(cEnd)
{
if(*e == _T('\0'))
cEnd = *e;
else if(*e == cTok)
*e = _T('\0');
if(*e)
e++;
else
{
if(*p != _T('\0'))
{
aryItem.Add(p);
nCount++;
}
p = ++e;
}
}
return nCount;
}