How would I go about changing this section of code so that the code that's used to check to see if the number of entries is equal to the maximum amount that could be entered to only be written once? Also, I would like it be reprinted menu and give control back to the user.
Code:
int numList; // Number of current filled entries
void crMenu(void)
{ // Displays Create DATABANK menu
int choice;
clrscr();
(numList > 1) || (numList == 0) ? printf("There are %d entries\n", numList) : printf("There is %d entry\n", numList);
printf("The list of possible question types avaliable");
printf("\n\t1. Direct");
printf("\n\t2. True or False");
printf("\n\t3. Fill in the blank");
printf("\n\t4. Multiple Choice");
printf("\n\t5. Back to main menu");
printf("\nYour choice ");
do
{
choice = getChoice();
switch(choice)
{
case (1) : if (numList >= NUM) // Number of maximum possible entries
{ printf("\nThe databank is full; you cannot add more\n");
pressKey();
crMenu();
}
directQuestion();
break;
case (2) : if (numList >= NUM) // Number of maximum possible entries
{ printf("\nThe databank is full; you cannot add more\n");
pressKey();
crMenu();
}
break;
case (5) : menu();
break;
default : printf("Enter a choice from the list\n");
pressKey();
break;
}
crMenu();
} while((choice > 1) || (choice < 5));
return;
}