2017-07-13 2 views
-1

私は、文字列をスペースを使ってベクトルに分割するプログラムをC++で作成しました。
今、whileループは何をしているのでしょうか? 読み込みが完了したら、ループから抜け出すにはどうすればよいですか? PS:私はそれがループを通って走っサイズ毎回を印刷し、それは私がそれはこれは私が現在取得しています何のサンプルである文字列内のすべての個々の数値を通じてC++:ユーザ入力から文字列をスペースを使ってベクトルに分割する

int main() 
{ 
    vector<string> postfix; 
    double result; 
    cout << "Please enter the postfix equation that you want to evaluate  Note: it can not be empty!\n"; 
    vector<string> expression; 
    string token; 
    while (cin >> token) 
    { 
     expression.push_back(token); 
     cout <<expression.size()<<endl; 
    } 

    postfix = expression; 
    evaluatePostfix(postfix,result); 
    cout <<"End"<<endl; 
} 

を行ったことを発見した方法は次のとおりです。

Please enter the postfix equation that you want to evaluate  Note: it can not 
be empty! 
6 9 7 1 2 
1 
2 
3 
4 
5 
+1

[ループ中の文字列ssの入力をもう何も示さないようにする方法(cin >> ss)](https://stackoverflow.com/questions/5360129/how-to-signify-no-more- string-ss-in-the-loop-while-cin-ss) – Blastfurnace

答えて

-1

一度入力するとwhileループを壊す文字を導入する必要がありますか?

関連する問題