センチネル値が入力されるまで、いくつかの 1 単語の入力を求める C++ プログラムを作成しようとしています。この値 (つまり「完了」) が入力されると、プログラムはユーザーが入力したすべての単語を出力する必要があります。
私は一般的な形式を持っています。ただし、これは文字列の複数の値を保存しません...どんな助けも素晴らしいでしょう、ありがとう。
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
string word;
word = "";
cout << "Enter the next bla bla now: " ;
cin >> word;
while ( word != "complete" )
{
cout << "The previous bla bla was: " << word << endl;
cout << "Enter the next bla bla now: ";
cin >> word;
}
cout << "Your phrase..bla bla bla is : " << word << endl;
return 0;
}