Answers for "string to vector separated by space"

C
1

string to vector separated by space

std::string s = "What is the right way to split a string into a vector of strings";
std::stringstream ss(s);
std::istream_iterator<std::string> begin(ss);
std::istream_iterator<std::string> end;
std::vector<std::string> vstrings(begin, end);
std::copy(vstrings.begin(), vstrings.end(), std::ostream_iterator<std::string>(std::cout, "\n"));
Posted by: Guest on September-18-2021

Code answers related to "string to vector separated by space"

Code answers related to "C"

Browse Popular Code Answers by Language