Solved

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

Posted on 2006-06-15
2
253 Views
Last Modified: 2010-04-01
string temp = "hello world";

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

thanks
0
Comment
Question by:rspiege1
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 50 total points
ID: 16915479
Sure, e.g.

string temp = "hello world";

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

if (-1 != pos) {

// "world" has been found

} else {

// nothing found
}
0
 

Author Comment

by:rspiege1
ID: 16915978
thanks, that was perfect
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question