请教个问题,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 = "香蕉";