I've got some problems with this code:
void selectOption(){
int choice; cin >> choice;
string name, surname;
switch(choice){
case 1:
showStudents();
break;
case 2:
cout <<"Name: "; cin >> name;
cout <<"Surname: "; cin >> surname;
addStudent(name,surname);
break;
case 3:
break;
default:
cout <<"DOES NOT SUPPORT" << endl;
break;
}
}
int main(){
while(true){
selectOption();
}
}
The problem is, whenever I enter a string, the program goes into the default
case instead of letting me enter a choice.
The second problem is, the program only works with 1, 2, and 3. If I write 5, nothing happens (it does not even go into the default
case).