topical media & game development

talk show tell print

professional-program-14-StringStream-StringStream.c

? / professional-program-14-StringStream-StringStream.c


  include <iostream>
  include <sstream>
  
  using namespace std;
  
  int main(int argc, char** argv)
  {
    cout << "Enter tokens. Control-D (Unix) or Control-Z (Windows) to end." << endl;
  
    ostringstream outStream;
  
    while (cin) {
      string nextToken;
  
      cout << "Next token: ";
      cin >> nextToken;
  
      if (nextToken == "done") break;
  
      outStream << nextToken << "\t";        
    }
  
    cout << "The end result is: " << outStream.str();
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.