over 4 years ago
std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) {
    std::stringstream ss(s);
    std::string item;
    while (std::getline(ss, item, delim)) {
    return elems;

std::vector<std::string> split(const std::string &s, char delim) {
    std::vector<std::string> elems;
    split(s, delim, elems);
    return elems;

Don't forget to include string, sstream and vector.

Reference: http://stackoverflow.com/questions/236129/how-to-split-a-string-in-c

← [C#] list all files in directory [Paper critique] Efficient visual search of videos cast as text retrieval →