首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

请问个有关问题,string.find()如何做,可以正确识别中文和英文混合

2012-08-26 
请教个问题,string.find()怎么做,可以正确识别中文和英文混合?C/C++ code#include iostream#include st

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

热点排行