Hi,
I am now with structures. After a hard day, I have a program that is able to get a menu with players data: name, age, height. The program works perfectly but I need an improvement. To get the menu, I use switch case but with 0,1,2,3. I must use A,B,C and I have in mind using 0 to exit the program. This is a very easy question: if I put A, B, C, 0 I get an error that those are undefinied variables. How can I make to put A,B,C in each case instead of 1,2,3? This is only a section of my code, the int main ()
Code:
int main()
{
struct players data[10];
int n, choice;
printf("Insert the number of registrations of players: ");
scanf("%d", &n);
read_players(data, n);
do {
printf("\nMenu :\n");
printf("Press 1 to print every name.\n");
printf("Press 2 to print every age.\n");
printf("Press 3 to print every height.\n");
printf("Press 0 to exit\n");
printf("\nInsert an option (1-3), 0 to exit : ");
scanf("%d", &choice);
switch (choice)
{
case 1:
print_names(data, n);
break;
case 2:
print_ages(data,n);
break;
case 3:
print_heights(data,n);
break;
}
}
while (choice != 0);
return 0;
}
This is only int main () if you need all the code (which is ok) I can put it. I need to substitute case 1, case 2, case 3 with case A, case B, case C (0 to exit).
Thank you in advance.