Answers for "c++ split string by space intro two variables"

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
0

c++ split string by several space

std::string s = "split on    whitespace   "; 
std::vector<std::string> result; 
std::istringstream iss(s); 
for(std::string s; iss >> s; ) 
    result.push_back(s);
Posted by: Guest on December-18-2020

Browse Popular Code Answers by Language