读书人

请问个有关问题string.find()如何做

发布时间: 2012-08-26 16:48:05 作者: rapoo

请教个问题,string.find()怎么做,可以正确识别中文和英文混合?

C/C++ code
#include <iostream>#include <string>using namespace std;int main (){    string lkwkeyword = "苹果,香蕉,ABC,OPQ,xyz";    string strTemp = "香蕉";        int posx = lkwkeyword.find(strTemp,0);    cout << posx;        return 0;   }



posx显示的是6,
但字面理解的应该是4或者3吧,应该怎么做才能不把汉字识别成2位呢?

[解决办法]
用wstring
C/C++ code
string lkwkeyword = "苹果,香蕉,ABC,OPQ,xyz";    string strTemp = "香蕉"; 

读书人网 >C++

热点推荐