tags:

views:

91

answers:

1

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

+3  A: 
void do_something(const std::string& word);

std::for_each( std::istream_iterator<std::string>(is)
             , std::istream_iterator<std::string>()
             , do_something );
sbi
It is `std::for_each`.
wilx
@wilx: Thanks, fixed it.
sbi