I'm trying to split a string that contains "|" into two parts.
if (size_t found = s.find("|") != string::npos) { cout << "left side = " << s.substr(0,found) << endl; cout << "right side = " << s.substr(found+1, string::npos) << endl; } This works with "a|b", but with "a | b", it will have "| b" as the right side. Why is that? How can this be fixed?