0
string str = "0.000 0.005 0.001";
istringstream s(str);
string sub;
while (s)
{
s >> sub;
cout << sub << endl;
}
這是我的代碼,我只想輸出str
中的每個數字,但我得到的最後一個數字是兩次。我知道有很多更好的方法來實現它,但我想知道這個代碼有什麼問題。我在operator>>
上遇到錯誤嗎?關於istringstream和>>運算符
該代碼不輸出每個數字兩次,它只輸出* last *數字兩次。 – Adam