How would you cut this line in 4 parts?
"The quick brown fox jumps over the lazy dog"
Like this:
The
quick
brown
fox jumps over the lazy dog
I cant seem to get the "fox jumps over the lazy dog" part.Code:#include <string> #include <vector> #include <iostream> #include <istream> #include <ostream> #include <iterator> #include <sstream> #include <algorithm> using namespace std; int main() { std::string str = "The quick brown fox jumps over the lazy dog"; stringstream ss; string s; ss << str; for(int i=0; i<4; i++) { (getline(ss, s, ' ')); cout << s << endl; } }