Find method in std::wstring
18,271
Solution 1
When searching a wstring, you need to have the parameter as a wide string as well
int index = strID.find(L"LABS");
^
Solution 2
int index = strID.find(L"LABS");
EDIT: http://msdn.microsoft.com/en-us/library/69ze775t(v=vs.80).aspx
Comments
-
Prabhu about 2 years
I have declared
Wstring
as followswstring 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?
-
thiton over 12 yearsYour answer is right, but would be much more informative if you would provide a short explanation of the why.