Hi, and thanks in advance for any help you can give me.
I have written 6 small programs and am trying to create a menu that allows the user to view whichever one they wish by calling from that file. I have written the code below for a menu but I don't know how to actually add in the programs themselves. Do they need to be in the same folder? Can the file names have spaces? Do I declare them somewhere at the beginning and then have the relevant one in the case statements?
Any help would be greatly appreciated.
Code:
#include <stdio.h>
/*Main Menu*/
int main ()
{
int choice;
printf("\n \t\t Programs \n");
printf("----------------------------------------------- \n");
printf("\t 1. Example Program 1 \n");
printf("\t 2. Example Program 2 \n");
printf("\t 3. Example Program 3 \n");
printf("\t 4. Example Program 4 \n");
printf("\t 5. Example Program 5 \n");
printf("\t 6. Example Program 6 \n");
printf("\t 0. Exit \n\n");
printf("Please choose which program you would like: \n");
scanf("%d", &choice);
printf("Choice = %d \n", choice);
switch (choice)
{
case 1 : printf("You have chosen program %d:Example Program 1 \n", choice) ; break;
case 2 : printf("You have chosen program %d:Example Program 2 \n", choice) ; break;
case 3 : printf("You have chosen program %d:Example Program 3 \n", choice) ; break;
case 4 : printf("You have chosen program %d:Example Program 4 \n", choice) ; break;
case 5 : printf("You have chosen program %d:Example Program 5 \n", choice) ; break;
case 6 : printf("You have chosen program %d:Example Program 6 \n", choice) ; break;
case 0 : printf("You have chosen %d to exit \n", choice) ; return ; break;
default : printf("This is not a valid choice. Please choose again"); break;
}
return 0;
}
Thanks again.