is there a way to search inside a string for another string in c++?

string temp = "hello world";

is there a way to search temp to see if the word "world" exists within it?

thanks
rspiege1Asked:
Who is Participating?
 
jkrConnect With a Mentor Commented:
Sure, e.g.

string temp = "hello world";

int pos = temp.find("world");

if (-1 != pos) {

// "world" has been found

} else {

// nothing found
}
0
 
rspiege1Author Commented:
thanks, that was perfect
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.