I have a code that gets a string of numbers that is separated by whitespace like:
"19 210 67"
And separates them and prints them out. But the thing is I want to put three them into an array one by one
so I have an array of strings like: ["19","210","67"]
How can I achieve that? Thanks.
Heres my C++ code:
std::string s = myText;
std::string delimiter = " ";
size_t pos = 0;
std::string token;
while ((pos = s.find(delimiter)) != std::string::npos) {
token = s.substr(0, pos);
std::cout << token << std::endl;
s.erase(0, pos + delimiter.length());
}
std::cout << s << std::endl;