次のコードを実行中にエラーが 1 回発生します
#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;
}
最後のトークン「you」を 2 回出力しますが、次の変更を行うとすべて正常に動作します。
while(iss >> tokens){
cout << tokens << endl;
}
while ループがどのように動作しているのか、誰か説明してもらえますか。ありがとう