Skip to content
loading...

Tokenize String Using C++

lucpattyn profile image Mukit, Ataul 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
Discussion
markdown guide
Classic DEV Post from Jul 30 '19

PublishTo.Dev: Scheduling article publishing on dev.to

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++