Tokenize String Using C++

twitter logo ・1 min read

std::string input = "We, are, all, strangers, here"; // our input
char delim = ','; // our delimiter


std::istringstream ss(input);
std::string token;

std::vector<std::string> tokens;
while(std::getline(ss, token, delim)) {
    tokens.push_back(token);
}

// tokens contain the array of tokenized strings separated by delimiter 
twitter logo DISCUSS
Classic DEV Post from May 19

Solving Puzzles With High-Performance JavaScript

Mukit, Ataul profile image
I consider myself as an enthusiast in learning new things everyday, about our history and future as well as the present. My interests: Ancient History, Comparative Religion, Science and Tech, C++