#include <sstream> string input; getline(cin, input); stringstream ss(input); string cur; while(ss >> cur) { process(cur); }