I have a problem that I've tried to solve several ways, I have a feeling I am missing something small so I am going to try to see if anyone here can point me in the right direction.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
while ( keep_going ){
cout << "Enter a word: ";
cin.getline( input, 80, '\n' ); // Accept up to 80 characters until users press' enter and load it into input as an array.
// I want to check if value of input is "END" if it is I want to set keep_going to false and exit the loop
if( input[0] == 'E' && input[1] == 'N' && input[2] == 'D' && input[3] == '/0' ){ // This does not exit at all
if( input == "END" ){ // This does not exit at all
if( input[0] == 'E' && input[1] == 'N' && input[2] == 'D' ){ // This one will exit when I type in END but will also exit if I enter ENDER or anything else that starts with end.
cout << "END command received, exiting now..." << endl;
keep_going = false;
break;
}
}
The three different if loops are not being entered at the same time this is just set up this way to demonstrate the different methods that I have tried. Is there some sort of test to try in the loop that will allow me to better test if the input was set to "END".