c++: how can i get a parcial string?

see these sample:
1
2
3
  string text="helloworld";
  if(text=="world")
      cout << "founded";

the C++ have 1 function for i find a parcial word on a string?
Administrator: thank you so much for add the code tags... thank you
Last edited on
1
2
3
4
if (text.find("world") != std::string::npos)
{
  cout << "founded";
}
correct me 1 thing: why compare with string npos?
Because the function string::find returns the value std::string::npos if the search term is not found.
thank you so much for all. thank you
Topic archived. No new replies allowed.