strin.cpp 445 B

12345678910111213141516
  1. // strin.cpp -- formatted reading from a char array
  2. #include <iostream>
  3. #include <sstream>
  4. #include <string>
  5. int main()
  6. {
  7. using namespace std;
  8. string lit = "It was a dark and stormy day, and "
  9. " the full moon glowed brilliantly. ";
  10. istringstream instr(lit); // use buf for input
  11. string word;
  12. while (instr >> word) // read a word a time
  13. cout << word << endl;
  14. // cin.get();
  15. return 0;
  16. }