cpp split string by space
std::vector<std::string> string_split(const std::string& str) { std::vector<std::string> result; std::istringstream iss(str); for (std::string s; iss >> s; ) result.push_back(s); return result; }
Source: www.quora.com
string split by space c++
// Extract the first token char * token = strtok(string, " "); // loop through the string to extract all other tokens while( token != NULL ) { printf( " %s\n", token ); //printing each token token = strtok(NULL, " "); } return 0;