Solved

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

Posted on 2006-06-15
2
255 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Which IDE to use to begin C++ training? 5 70
GUI: DIalog Stacking and Popping in MS C++ 4 87
Autosar OS Multicore Share Resources confusion ? 2 99
boost::uuid crashes 17 35
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

685 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