1std::vector<std::string> string_split(const std::string& str) {
2 std::vector<std::string> result;
3 std::istringstream iss(str);
4 for (std::string s; iss >> s; )
5 result.push_back(s);
6 return result;
7}
1// Extract the first token
2char * token = strtok(string, " ");
3// loop through the string to extract all other tokens
4while( token != NULL ) {
5 printf( " %s\n", token ); //printing each token
6 token = strtok(NULL, " ");
7}
8return 0;