如何查找字符串中的小字符串个数? 如何查找字符串中的小字符串个数?比如在字符串 "abcadfbcaebf" 中 查找 'b'的个数或 "ca"的个数 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 另,哪位兄弟有CString 类函数的使用大全、详解一类的?最好是中文的。给个链接啊。MSDN看着费劲 CString str; str = "abcadfbcaebf"; int nCount1=0, nCount2=0; for(int i=0; i<str.GetLength(); i++) { if(str[i] == 'b') nCount1++; } while( !str.IsEmpty() ) { int index; if( (index = str.Find("ca")) != -1) { nCount2++; str = str.Mid(index+2); } else break; } int Substr(CString str,CString sub){ int nRet= 0, nStart = 0; while(-1!=(nStart=str.Find(sub,nStart))) { nStart+=sub.GetLength(); ++nRet; } return nRet;}usage:int n=Substr("abcadfbcaebf","b");int n=Substr("abcadfbcaebf","ca"); 急啊,问一个关于Post网络问题,分不够再散 简单问题,在线等,赠送20分,一解决马上给分 为什么总是提示类未注册? 用MFC 的SOCKET编程如何设置超时,如何判断网络异常,例如网络断掉。 用什么函数限定鼠标移动的范围。dialog中一个圆的范围,不是整个dialog 请教 listctrl修改默认高度的问题 CView中如何嵌入OCX? MFC 图片选择控件如何做呢?谢谢大家 关于Project 2000解密,急!急!!急!!! 我的代码有问题吗? COledatetime在2000和xp下的版本冲突问题。
str = "abcadfbcaebf";
int nCount1=0, nCount2=0;
for(int i=0; i<str.GetLength(); i++)
{
if(str[i] == 'b')
nCount1++;
}
while( !str.IsEmpty() )
{
int index;
if( (index = str.Find("ca")) != -1)
{
nCount2++;
str = str.Mid(index+2);
}
else
break;
}
{
int nRet= 0, nStart = 0;
while(-1!=(nStart=str.Find(sub,nStart)))
{
nStart+=sub.GetLength();
++nRet;
}
return nRet;
}usage:
int n=Substr("abcadfbcaebf","b");
int n=Substr("abcadfbcaebf","ca");