Entries from 2016-01-17 to 1 day

Split a string in C++11

The example below works just like PHP's explode. std::vector<std::string> tokenize(const std::string& s, char c) { auto end = s.cend(); auto start = end; std::vector<std::string> v; for( auto it = s.cbegin(); it != end; ++it ) { if( *it != c ) { if( start == end ) </std::string></std::string>…