I have been at this for a while and I just cant seem to figure out why this is not able to exit the loop once I input STOP. The value for more changes in the loop. I would appreciate any help, many thanks.
#include <iostream>
#include <string>
int main(){
std::string STOP, n, more="yes";
while(more=="yes"){
std::cout<< " please enter a word" << std::endl;
std::cin >> n;
if(n==STOP){
more="no";
}
else{
std::cout << n << std::endl;
}
}
return 0;
}
The idea is that more would be yes to begin with to enter the loop. After this the question is asked and whatever is inputted would be repeated and the question asked again however if what is input is the word STOP this would exit the loop and it ends.
YES! I have just adjusted the value of STOP to STOP and now it does exit the loop. Thank you. Not sure if having 3 variables to do this is the most efficient way though.