#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>

using namespace std;

int main () {

    string test = "   first     \"  in \\\"quotes \"  last";
    istringstream strm(test);

    while (!strm.eof()) {

        string token;
        auto startpos = strm.tellg();
        strm >> quoted(token);
        auto endpos = strm.tellg();
        if (endpos == -1) endpos = test.length();

        cout << token << ": " << startpos << " " << endpos << endl;

    }

}
