for example i have a string:
string s = \"apple | orange | kiwi\";
and i searched and there is a way:
stringstream stream(s
As Benjamin points out, you answered this question yourself in its title.
#include
#include
#include
int main() {
// inputs
std::string str("abc:def");
char split_char = ':';
// work
std::istringstream split(str);
std::vector tokens;
for (std::string each; std::getline(split, each, split_char); tokens.push_back(each));
// now use `tokens`
}
Note that your tokens will still have the trailing/leading
characters. You may want to strip them off.