So I need to let a user be able to enter in as many words as they want until they enter stop. Once they enter stop the code is suppose to for all of the words into a sentence. Have got this far but once I enter stop it continues to allow me to enter words. Need help please
#include "stdafx.h"
#include <iostream>
#include <string>
usingnamespace std;
int main ()
{
bool quit;
string word, sentence;
cout << "Sentence Builder" << endl;
// prompt the user for a word, (stop to quit)
cout << "Please enter a word or enter stop to quit: ";
// read the user input into word
cin >> word;
// initialize the loop control variable
quit = word.compare("stop") == 0;
while(!quit)
{
// concatenate the word to the sentence
sentence = sentence + " " + word;
// prompt the user for a word, stop to quit
cout << "Please enter in another word or enter stop to end the program: ";
// read the user input into word
cin >> word;
// update the LCV (same as initialize)
sentence = word + word;
}
cout << sentence << "." << endl;
system("pause");
return 0;
}