Skip to content

Instantly share code, notes, and snippets.

@clauswitt
Created July 22, 2015 11:40
Show Gist options
  • Save clauswitt/29762b766d9a7bcf44f2 to your computer and use it in GitHub Desktop.
Save clauswitt/29762b766d9a7bcf44f2 to your computer and use it in GitHub Desktop.
Split a string with boost
#include <iostream>
#include <string>
#include <vector>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>
int main() {
std::string result;
std::string str01 = "this,is,a,list,of,words";
std::vector<std::string> parts;
boost::split(parts , str01, boost::is_any_of(","));
for (std::vector<std::string>::const_iterator i = parts.begin(); i != parts.end(); ++i)
std::cout << *i << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment