Bill the Lizard Bill the Lizard - 2 months ago 10
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++?

Answer

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.