Answers for "split string by space into array c++"

C++
1

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;
}
Posted by: Guest on March-01-2021
1

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( " %sn", token ); //printing each token
  token = strtok(NULL, " ");
}
return 0;
Posted by: Guest on April-21-2021

Code answers related to "split string by space into array c++"

Browse Popular Code Answers by Language