split a string in C++

This is my favourite way to iterate through a string. You can do what you want per word.

 

string line = "a line of text to iterate through";
string word;

istringstream iss(line, istringstream::in);

while( iss >> word )     
{

...

}

 

posted @ 2014-12-26 04:38  zmiao  阅读(123)  评论(0编辑  收藏  举报