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 Feb 8

Why you may need a dedicated homelab.

When that good ol' PC won't cut it anymore.

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

Sore eyes?

dev.to now has dark mode.

Go to the "misc" section of your settings and select night theme ❀️

(There is also a pink mode)