// ========================================================================== // $Id: stringstream.cpp,v 1.2 2010/10/20 14:30:46 jlang Exp $ // CSI2372 example Code for lecture 8 // ========================================================================== // (C)opyright: // // Jochen Lang // SITE, University of Ottawa // 800 King Edward Ave. // Ottawa, On., K1N 6N5 // Canada. // http://www.site.uottawa.ca // // Creator: jlang (Jochen Lang) // Email: jlang@site.uottawa.ca // ========================================================================== // $Log: stringstream.cpp,v $ // Revision 1.2 2010/10/20 14:30:46 jlang // Added non-std algorithm compiler switch // // Revision 1.1 2006/10/17 22:18:48 jlang // Added examples for lecture 8 // // // ========================================================================== // #define WITH_STD_ALGORITHM #include #include #include #ifdef WITH_STD_ALGORITHM // transform is a std algorithm #include #endif using namespace std; int main() { string line, token; // Get a line while (getline(cin, line)) { istringstream streamLine(line); cout << "Got: " << line << endl; // Get individual white space separated tokens cout << "Tokens: " << endl; while ( streamLine >> token ) { // Process word cout << token << endl; #ifdef WITH_STD_ALGORITHM transform( token.begin(), token.end(), token.begin(), static_cast(tolower) ); #else for ( int i=0; i