I have a function recieving a string, which is a pair of comma delimited integers in a fashion such as \"12,4\". How can I parse the integers out of this string?
Depends whether or not you can depend on the incoming data being valid. If you can, I'd do:
#include #include #include std::pair split(std::string const& str) { int const a = std::atoi(str.c_str()); int const b = std::atoi(str.c_str() + str.find(',') + 1); return std::make_pair(a, b); }