Last active
January 31, 2024 00:42
-
-
Save SeungYup26/8199334a3f11a9cf598df258cfd2c568 to your computer and use it in GitHub Desktop.
C++17 split string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C++ 17 | |
#include <iostream> | |
#include <sstream> | |
#include <string> | |
#include <vector> | |
std::vector<std::string> split(const std::string& target, char c) | |
{ | |
std::string temp; | |
std::stringstream stringstream { target }; | |
std::vector<std::string> result; | |
while (std::getline(stringstream, temp, c)) { | |
result.push_back(temp); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment