Another quick way is to use getline
. Something like:
stringstreamstd::istringstream ssiss("bla bla"str);
std::string s;
while (std::getline(ssiss, s, ' ')) {
std::cout << s << std::endl;
}
If you want, you can make a simple split()
method returning a std::vector<string>
, which is
really really useful.