0

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

Community
  • 1
  • 1
Anonymous
  • 1,287
  • 6
  • 20
  • 21

1 Answers1

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

std::for_each( std::istream_iterator<std::string>(is)
             , std::istream_iterator<std::string>()
             , do_something );
sbi
  • 219,715
  • 46
  • 258
  • 445