统计字符串中某个字符出现的次数
用标准库算法函数“ count_if”。
1、标准库string类型
const stringstr = “testString”;
int count = count_if( str.begin(), str.end(), bind2nd(equal_to<char>(), '某字符' );
2、CString类型
CString str = “testString”;
int count = count_if( (LPCTSTR)str, (LPCTSTR)str+str.GetLength(), bind2nd(equal_to<TCHAR>(), _T('某字符')) );