DEV Community


Tokenize String Using C++

lucpattyn profile image Mukit, Ataul ・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 contain the array of tokenized strings separated by delimiter 

Discussion (0)

Forem Open with the Forem app