Skip to content

Instantly share code, notes, and snippets.

@2GMon
Created August 23, 2012 03:05
Show Gist options
  • Save 2GMon/3431716 to your computer and use it in GitHub Desktop.
Save 2GMon/3431716 to your computer and use it in GitHub Desktop.
boost::algorithmで文字列split
#include <iostream>
#include <string>
#include <list>
#include <boost/tokenizer.hpp>
#include <boost/algorithm/string.hpp>
int main(int argc, char const* argv[])
{
std::string str = "piyo,huga,hoge";
std::list<std::string> splitted;
boost::algorithm::split(splitted, str, boost::is_any_of(","));
std::list<std::string>::iterator it;
for (it = splitted.begin(); it != splitted.end(); ++it)
std::cout << *it << ": ";
std::cout << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment