I think the function you want is string.substring which returns a string using two element positions so that you just search for the space char and get it's postion then find the next one and get the word between those two spaces, then move on to the next space, etc.
there's also a string stream object that you can use to extract from strings word at a time using the << operator
PHP Code:
//compiled in VC++ 6 as a 32bit console app
#include <iostream>
using namespace std;
#include <string>
int main()
{
string Test123=" one two three";
string myBuf;//this will be where I put the piece of the string
int prevPos=Test123.size()-1;//this will store the end of the sub string
int nextPos=Test123.size()-1;//and the beginning of the sub string
//whatever is inbetween will be the word
//I initilize them to both be at the end of the string
//rfind returns string.npos if the string we search for is not found
//since I searched for a space then if it does not find it then it has reached the end
//but that just means there might be another word to read since the line might not end in a space
while((Test123.npos != nextPos)&&(nextPos))//this would mean we've reached the end of the string, the AND nextPos would be a case where the string contained a space at the begining
{
prevPos=nextPos;//we're fixing to move nextPos to the next space but we want to know where it came from
//rfind starts searching for a string at the right end of the string and moves left until it finds it
//then returns the element position of that string we searched for
nextPos=Test123.rfind(" ", prevPos);
if(nextPos==Test123.npos)//this tells me it didn't find a space last time so we are now at the beginning of the file
{
nextPos=0;
myBuf= Test123.substr(nextPos, (prevPos+1));//returns a string between next and prev
}
else
{
nextPos+=1;//this is a technicality, you have to move it back a little so that you don't get the space
//stores the string starting at nextPos, and stores number of chars defined by second param
myBuf= Test123.substr(nextPos, (prevPos-nextPos+1));
//try running debug, go to View, Debug Windows, Watch, type in Test123.substr(4,3) and hit enter, play with the parmeters
if(nextPos==1)//this would be if we just read the last word and the string happens to contain a space at the beggining
nextPos+=1;//add 1 so that we don't try to subtract 2 from 1, this would mean nextPos becomes 0 in the next statement
nextPos-=2; //and then moves it over the space so that we don't get stuck finding it over and over again
}
//for demonstration puroses :>
cout<<myBuf<<" ";
//notice that rfind searches from right to left so you get the words out in right to left order
}
return 0;
}