Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main() {
- string s = "What is the right way to split a string into a vector of strings";
- stringstream ss(s);
- istream_iterator<string> begin(ss);
- istream_iterator<string> end;
- vector<string> vstrings(begin, end);
- copy(vstrings.begin(), vstrings.end(), ostream_iterator<string>(cout, "\n"));
- return 0;
- }
- // by http://stackoverflow.com/questions/5607589/right-way-to-split-an-stdstring-into-a-vectorstring
- /*
- Other links info :
- http://stackoverflow.com/questions/5167625/splitting-a-c-stdstring-using-tokens-e-g
- http://stackoverflow.com/questions/1894886/parsing-a-comma-delimited-stdstring
- */
Advertisement
Add Comment
Please, Sign In to add comment