Skip to content

Instantly share code, notes, and snippets.

@NewbiZ
Created December 6, 2010 08:12
Show Gist options
  • Save NewbiZ/730008 to your computer and use it in GitHub Desktop.
Save NewbiZ/730008 to your computer and use it in GitHub Desktop.
Split a string using a delimiter
void split( const std::string& str, char delim, std::vector<std::string>& tokens )
{
std::stringstream iss(str);
std::string item;
while ( std::getline(iss, item, delim) )
{
if ( !item.empty() )
tokens.push_back(item);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment