Support Board
Date/Time: Mon, 25 Nov 2024 21:33:19 +0000
Post From: Parse a comma delimited string
[2024-02-06 19:18:23] |
User719512 - Posts: 264 |
Posting here for others who might stumble upon this thread. ChatGPT is very good at answering questions like this as well. StackOverflow as well. std::list<int> ParseCommaSeparatedIntegers(const std::string& input) { std::list<int> result; std::istringstream iss(input); std::string token; while (std::getline(iss, token, ',')) { if (!token.empty()) { result.push_back(std::stoi(token)); } } return result; } ... std::list<int> items = ParseCommaSeparatedIntegers(input); for (int item: items) { ... |