bool verify2 = false;
while(verify2 == false)
bool verify = false;
cout << "Which field would you like to inquire about?" << "\n";
cout << "Action, Strength, or Diagnostic?" << "\n";
cout << "If you would like to quit please enter Q or q" << endl;
response = lowercase(response);//Converts response to lowercase letters
if(response == "strength")
verify = true; //Changed to true if it enter this if statement
if(response == "action")
verify = true;
if(response == "diagnostic")
verify = true;
if(response == "q")
verify2 = true;
cout << "Goodbye." << endl;
elseif(verify == false || response.empty()) //If it hasnt entered either of the statements this will print
cout << "Your input was not recognized. Please check spelling." << "\n" << endl;
Hey guys/gals I need some serious help before I go insane. I've written this function with the intent to give users the choice and once the choice is selected to go to the other function and do its thing. My problem is when it runs and I choose action, it completes its purpose and it repeats the action function. The same for the other two (strength and diagnosis). I've tried placing option() again after action is called in the same if statement to see what would happen. After I did so the menu came up and no matter what I select the action function keeps repeating. I've tried choosing to quit after action or any of the other functions are called and it wouldn't quit. The only way the program quits is if quit is my first option.
I know one solution is just to put exit(), but I don't want to do that. I want the variables and statements to do what they are supposed to.
I would hate to find out it's some minor foolishness.
long as the user has not entered anything, getline will still be waiting for input
Nope. getline() will store all characters it encounter into response until delimeter (default '\n') is found. Then it discards it and stops. If user just presses enter, getline will store an empty string.
Thou I don't know exactly if this will fix it, but worth a try, I guess.
A: Make the entire if section an "if else" section instead (ie, add the word "else " to the beginning of line 22, 29 and 35)
B: Remove the if statement on line 41
C: Remove line 44
Don't know if that will work, but hey, why not give it a whirl?