language: C++ 4.7.2 (gcc-4.7.2)
date: 769 days 15 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <iterator>
#include <vector>
 
int main() {
        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"));
        return 0;
}
  • upload with new input
  • result: Success     time: 0s    memory: 2864 kB     returned value: 0

    What
    is
    the
    right
    way
    to
    split
    a
    string
    into
    a
    vector
    of
    strings