Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //PatientDatabase0.0.3
- //Simon Loftén
- //2018-10-15
- #include <stdio.h>
- #include <stdbool.h>
- void startupConfig();
- void patientHandling();
- char menuInputValidCheck(char input);
- bool menuHandler(char input);
- int main(void){
- startupConfig();
- patientHandling();
- return 0;
- }
- void startupConfig(){
- printf("\tThis is your startupConfig call\n");
- }
- void patientHandling(){
- bool programOnSwitch = true;
- char menuInput;
- while(programOnSwitch == true){
- printf("\tThis is where the main menu gets called\n");
- printf("\tThe menu is active as long as the user doesn't quit the program,\n\tif he/she does, programOnSwitch is set to false\n");
- printf("\n\tWhat menu would you like? [a, b, c, d or quit (q)]\n");
- scanf(" %c", &menuInput);
- menuInput = menuInputValidCheck(menuInput);
- programOnSwitch = menuHandler(menuInput);
- }
- }
- char menuInputValidCheck(char input){
- while(input != 'a' && input != 'b' && input != 'c' && input != 'd' && input != 'q'){
- printf("\tInput wrong, please try again\n");
- scanf(" %c", &input);
- }
- return input;
- }
- bool menuHandler(char input){
- printf("\n\tThis is where the menu call gets forwarded to the correct sub menu\n");
- switch(input){
- case 'q' :
- printf("\n\tYou did press q, and the programOnSwitch is set to false\n");
- return false;
- default :
- printf("\n\tYou did not press q, you pressed %c\n", input);
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement