a problem with strpbrk

Hello. With CodeBlocks 10.05 and XP i have the report ...
-----------------------------------
'bool StringUtils::strBlngsTo(const std::string&, const std::string&)':| 'strpbrk' was not declared in this scope|
||=== Build finished: 1 errors, 0 warnings ===|
-----------------------------

1
2
3
4
5
bool StringUtils::strBlngsTo(const std::string& s1, const std::string& s2)
{
  if (strpbrk (s1.c_str(), s2.c_str()))return  true;
  return false;
}


The code ...

1
2
3
4
5
bool StringUtils::strBlngsTo(const std::wstring& s1, const std::wstring& s2)
{
  if (wcspbrk(s1.c_str(), s2.c_str()))return true;
  return false;
}


works just fine. With previus version codeblocks 8.05 i have no problem.

Any idea?
Last edited on
Couldn't you just you .find()? i.e.:

return s1.find(s2);
Did you include cstring?
Edit: find is of course better.
Should be:
return s1.find(s2)!=string::npos;
Last edited on
But strpbrk returns a pointer to the first occurrence in str1 of any of the characters that are part of str2, or a null pointer if there are no matches.
Why not work in CB 10.05, and wcspbrk works? This is the question.
Ah, ok then:

s1.find_first_of(s2);
Why not work in CB 10.05, and wcspbrk works? This is the question.

Because strpbrk is part of the C++ standard (defined in cstring) and wcspbrk is not. Therefore, wcspbrk is declared in some other header file that you already included directly or indirectly somewhere.
Last edited on
Thank's a lot, i must search the headers. Ok.
Topic archived. No new replies allowed.