fork download
  1. #include <iostream>
  2. #include <sstream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main() {
  7. istringstream ch{"this is-a\tstring.It has\n6 words."};
  8. string w;
  9.  
  10. for(auto i = 1; ch >> w; ++i) {
  11. cout << i << ": " << w << endl;
  12. }
  13. return 0;
  14. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
1: this
2: is-a
3: string.It
4: has
5: 6
6: words.