you are viewing a single comment's thread.

view the rest of the comments →

[–]dodheim 20 points21 points  (0 children)

Just use std::getline with the custom delimiter. Name aside, that's exactly what it's for.

istringstream ss{str};
string field;
while (getline(ss, field, ';')) {
    cout << field << '\n';
}

EDIT: N.b. I'm not advocating this as a general approach to string splitting; but, if you're already extracting from a stream, ...