CString 对中文遍历匹配
对型如英文的字符串遍利:并且匹配 'e '
char *p= "abcedef ";
int i=0;
while(*p!= '\0 ')
{
cout < < "p[ " < <i < < "]= " < <*p < <endl;
if(*p== 'e ')
{
cout < < "在 " < <i < < "的位置匹配e " < <endl;
break;
}
i++;p++;
}
现有CString s= "我们都爱学习 ";并且匹配 '都 '
实现类似上面的功能. 用string类型或其他类型都行,只要是对中文处理.
[解决办法]
string str( "我们都爱学习 ");
int pos = str.find( "都 ");
cout < < "pos is " < <pos < <endl;