Bill the Lizard Bill the Lizard - 7 months ago 43
C++ Question

How do I tokenize a string in C++?

Java has a convenient split method:

String str = "The quick brown fox";
String[] results = str.split(" ");

Is there an easy way to do this in C++?


Your simple case can easily be built using the std::string::find method. However, take a look at Boost.Tokenizer. It's great. Boost generally has some very cool string tools.