执行以下代码时出现一个错误
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main (int argc, char* argv[]){
string tokens,input;
input = "how are you";
istringstream iss (input , istringstream::in);
while(iss){
iss >> tokens;
cout << tokens << endl;
}
return 0;
}
它两次打印出最后一个标记“你”,但是如果我进行以下更改,一切正常。
while(iss >> tokens){
cout << tokens << endl;
}
谁能解释一下while循环是如何运行的。谢谢