C++ CSV line with commas and strings within double quotes
Using std::quoted allows you to read quoted strings from input streams. #include <iomanip> #include <iostream> #include <sstream> #include <string> int main() { std::stringstream ss; ss << “\”Primary, Secondary, Third\”, \”Primary\”, , \”Secondary\”, 18, 4, 0, 0, 0″; while (ss >> std::ws) { std::string csvElement; if (ss.peek() == ‘”‘) { ss >> std::quoted(csvElement); std::string discard; std::getline(ss, … Read more