#define MAXSPACE 25
string line = "test one two three.";
string arr[MAXSPACE];
string search = " ";
int spacePos;
int currPos = 0;
int k = 0;
int prevPos = 0;
do
{
spacePos = line.find(search,currPos);
if(spacePos >= 0)
{
currPos = spacePos;
arr[k] = line.substr(prevPos, currPos - prevPos);
currPos++;
prevPos = currPos;
k++;
}
}while( spacePos >= 0);
arr[k] = line.substr(prevPos,line.length());
for(int i = 0; i < k; i++)
{
cout << arr[i] << endl;
}