5

我声明Wstring如下

wstring strID

当我尝试查找出现的子字符串时,如下所示

int index =   strID.find("LABS");

我收到如下错误

error C2664: 'unsigned int std::basic_string<_Elem,_Traits,_Ax>::find(const std::basic_string<_Elem,_Traits,_Ax> &,unsigned int) const' : cannot convert parameter 1 from 'const char [13]' to 'const std::basic_string<_Elem,_Traits,_Ax> &'

你能帮我找到子字符串的出现吗?

4

2 回答 2

18

搜索 wstring 时,您还需要将参数作为宽字符串

int index =   strID.find(L"LABS"); 
                         ^
于 2011-12-27T12:55:25.287 回答
3
int index =   strID.find(L"LABS");

编辑: http: //msdn.microsoft.com/en-us/library/69ze775t (v=vs.80).aspx

于 2011-12-27T12:56:04.047 回答