#include #include #include using namespace std; static string reverseWords(string const& instr) { istringstream iss(instr); string outstr; string word; iss >> outstr; while (iss >> word) outstr = word + ' ' + outstr; return outstr; } int main() { string s = " one two \t three four "; string sret = reverseWords(s); cout << "in='" << s << "' " << "out='" << sret << "'" << endl; return 0; }