Boolean Loop Problem

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace 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;
}
Well, assuming the first word isn't stop, the code never checks for the word stop again.

The program enters the loop, but notice that the loop doesn't have any checks, nor does the code ever break out of the loop.
Topic archived. No new replies allowed.