Original Post
I''m trying to write a function to split a std::string but it loops forever in the while loop:
void Split(std::vector<std::string> &out,
const std::string &str,
const std::string &delim)
{
std::string::size_type firstPos, secondPos;
firstPos = str.find_first_of(delim);
out.push_back(str.substr(0, firstPos));
while (firstPos != std::string::npos)
{
secondPos = str.substr(firstPos).find_first_of(delim);
out.push_back(str.substr(firstPos + 1, secondPos - firstPos));
firstPos = secondPos;
}
}It probably something obvious, as always when I ask something here