Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find method in std::wstring

I have declared Wstring as follows

wstring strID

When I try to find the occurrences sub-string as follows

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

I am getting error like the following

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> &'

Can you please help me to find the occurrences of sub-string?

like image 468
Prabhu Avatar asked Dec 27 '11 12:12

Prabhu


2 Answers

When searching a wstring, you need to have the parameter as a wide string as well

int index =   strID.find(L"LABS"); 
                         ^
like image 78
Bo Persson Avatar answered Oct 22 '22 22:10

Bo Persson


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

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

like image 28
user1097489 Avatar answered Oct 22 '22 22:10

user1097489