开发者

how to extract words from a string in C++ [duplicate]

This开发者_StackOverflow中文版 question already has answers here: Closed 12 years ago.

Possible Duplicate:

How do I tokenize a string in C++?

I have a string "this is a string", and I want to iterate over all the words in this string. Is there a way in which i can easily do this without having to parse it.

Thanks


void do_something(const std::string& word);

std::for_each( std::istream_iterator<std::string>(is)
             , std::istream_iterator<std::string>()
             , do_something );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜