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