how do i make sure that the switch case doesnt ternimate the program if the entry is invalid.
in my program, if user input is y, removes the file. if user input is n, exits program, if user input is anything else prints out error message prompts for user input again and if that is a invalid input it terminates program. i dont want it to terminate the program. until the correct input is entered, it needs to prompt the user.
in my program, if user input is y, removes the file. if user input is n, exits program, if user input is anything else prints out error message prompts for user input again and if that is a invalid input it terminates program. i dont want it to terminate the program. until the correct input is entered, it needs to prompt the user.
Code:
char option; cin >> option; switch (option){ case 'y' : remove("file.txt"); break; case 'n' : exit(0); default : cout << "Invalid entry" << endl; cin >> option; }
Comment