Skip to content

Instantly share code, notes, and snippets.

@SeungYup26
Last active January 31, 2024 00:42
Show Gist options
  • Save SeungYup26/8199334a3f11a9cf598df258cfd2c568 to your computer and use it in GitHub Desktop.
Save SeungYup26/8199334a3f11a9cf598df258cfd2c568 to your computer and use it in GitHub Desktop.
C++17 split string
// 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