fork download
  1. #include <iomanip>
  2. #include <iostream>
  3. #include <sstream>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. int main () {
  9.  
  10. string test = " first \" in \\\"quotes \" last";
  11. istringstream strm(test);
  12.  
  13. while (!strm.eof()) {
  14.  
  15. string token;
  16. auto startpos = strm.tellg();
  17. strm >> quoted(token);
  18. auto endpos = strm.tellg();
  19. if (endpos == -1) endpos = test.length();
  20.  
  21. cout << token << ": " << startpos << " " << endpos << endl;
  22.  
  23. }
  24.  
  25. }
  26.  
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
first: 0 8
  in "quotes : 8 29
last: 29 35