Frequently, you may need to isolate words in a phrase. In this example, we'll use substr to carry out this task.

string phrase = "Now is the oppurtunity to claim money";
string word;
int i, space;
phrase+=" ";//add space to end of phrase
while(phrase.length()>0)
{
space = phrase.find();//find position of the first space in phrase
word = phrase.substr(0,space);
//process word here and then go to next word
cout<<word<<endl;
phrase = phrase.substr(space+1);//create new phrase with first word chopped off
}//end while phrase

Another way to get the substrings of the given string with spaces as delimiters can be

#include<string>
#include<sstream>
using namespace std;

string givenString="This is the string to be split";
stringstream s;
string temp;
s<<givenString;
while(s>>temp)
cout<<temp<<endl;

Thank you guys for your comment, will be posting a few more within the next week or so.

The article starter has earned a lot of community kudos, and such articles offer a bounty for quality replies.