int main(int argc, char* argv[]) { string str = "the big blue dog ate food."; int pos; while((pos = str.find(' ')) > 0) { string sub = str.substr(0,pos); str = str.substr(pos+1); cout << sub << endl; } return 0; }