I'm currently writing a program that needs to except an option then followed by a piece of text if the piece of text. if the text is true then a piece of code executes? At least I think that's how it works, however, the program goes straight to the else and keeps looping because of the initial condition it doesn't ask the another input from the user which is getline() ?
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
int main() {
fstream gFile;
int choice;
string gb;
do {
cout << "Student Grade Book Info Program....\n";
cout << "\tPlease Select an Option: (1 or 2) \n" << endl
<< "\t1. Review Grades"
<< "\n\t2. Quit"
<< "\n\tChoose: ";
cin >> choice;
switch (choice) {
case 1:
cout << "\n\tPlease Enter the Name of the File you wish to View the Grades for: " << endl;
cout << "\n\tAvailable Grade Books: gradeBook\n" <<
"\tType in the Grade Book you would like to view. ";
getline(cin, gb);
if (gb == "gradeBook") {
cout << "execute code...";
}
else {
cout << "\nError there is no such entry in the system." << endl;
}
case 2:
break;
}
} while (choice != 2);
return 0;
}