I am developing a system for college and would like to know the best option, in the sense of code optimization, even improvement.
I have switch
case for Menu, where I have 88 cases.
I have a screen called "Help", in this screen, the user can choose between 88 screens.
Example below:
To access the "Help" screen, it should type "help"
It will access this screen telaAjuda ();
with several options inside it.
These options are between 1 and 88. Example below:
printf("\n\t Op1 ...................................1\n");
printf("\n\t Op2....................................2\n");
printf("\n\t Op3....................................3\n");
printf("\n\t Op4....................................4\n");
printf("\n\t Op5...................................5\n\n");
...
printf("\n\t Op88...................................88\n\n");
And according to what is chosen, the user is taken to another screen of a certain number (as if it were a book pagination scheme).
If he chooses and enters the number 3, he will be taken to the Op3 screen.
The screen that uses switch case
is subMenu_Ajuda ()
, which I call it below the help (I did two distinct functions for this, because if I want to call the help submenu elsewhere in the code, I will not need necessarily call the screen helps together), only to receive the value entered by the user and from it, choose the option in switch case
.
Example below the submenu_help:
printf("\nnomePrograma : loginUsuario -> "); //usarlogin
scanf("%i", &opAjuda);
switch (opAjuda) { //88 Cases
case 1:
system("clear");
telaAjuda1 ();
__fpurge(stdin);
break;
case 2:
system("clear");
telaAjuda2 ();
__fpurge(stdin);
break;
...
case 88:
system("clear");
telaAjuda88 ();
__fpurge(stdin);
break;
}
Can I leave switch case
of this same size or should I create a vector for all cases
and call it when needed?