Advertisement
Guest User

Untitled

a guest
Oct 20th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.43 KB | None | 0 0
  1. //PatientDatabase0.0.3
  2. //Simon Loftén
  3. //2018-10-15
  4.  
  5. #include <stdio.h>
  6. #include <stdbool.h>
  7.  
  8.  
  9. void startupConfig();
  10. void patientHandling();
  11. char menuInputValidCheck(char input);
  12. bool menuHandler(char input);
  13.  
  14.  
  15. int main(void){
  16.    
  17.     startupConfig();
  18.     patientHandling();
  19.    
  20.     return 0;
  21. }
  22.  
  23. void startupConfig(){
  24.     printf("\tThis is your startupConfig call\n");
  25. }
  26.  
  27. void patientHandling(){
  28.    
  29.     bool programOnSwitch = true;
  30.     char menuInput;
  31.    
  32.     while(programOnSwitch == true){
  33.        
  34.         printf("\tThis is where the main menu gets called\n");
  35.         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");
  36.         printf("\n\tWhat menu would you like? [a, b, c, d or quit (q)]\n");
  37.         scanf(" %c", &menuInput);
  38.        
  39.         menuInput = menuInputValidCheck(menuInput);
  40.         programOnSwitch = menuHandler(menuInput);
  41.     }
  42. }
  43.  
  44. char menuInputValidCheck(char input){
  45.     while(input != 'a' && input != 'b' && input != 'c' && input != 'd' && input != 'q'){
  46.         printf("\tInput wrong, please try again\n");
  47.         scanf(" %c", &input);
  48.     }
  49.     return input;
  50. }
  51.  
  52. bool menuHandler(char input){
  53.     printf("\n\tThis is where the menu call gets forwarded to the correct sub menu\n");
  54.    
  55.     switch(input){
  56.         case 'q' :
  57.             printf("\n\tYou did press q, and the programOnSwitch is set to false\n");
  58.             return false;
  59.         default :
  60.             printf("\n\tYou did not press q, you pressed %c\n", input);
  61.             return true;
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement