So, i have this code:
#include <stdio.h>
void menu_loop(int run) {
if (run == 0) {
printf("bad\n");
menu();
}
else
printf("good");
}
int check_menu(int menu1) {
if (menu1 > 3 || menu1 < 0)
return 0;
else
return 1;
}
int menu() {
int choice;
printf("----MENU----\n0 -> Exit\n1 -> Prime time\n2 -> Calander calculating\n3 -> Matrix printing\n");
scanf_s("%d", &choice);
int check2 = check_menu(choice);
menu_loop(check2);
}
void main() {
menu();
}
what i need to do is whenever check_menu returns a 0 then i need to have a certein variable that starts at 0 go up by 1. everytime i try this i find that the value gets reinitialized to 0 since im initializing it inside the function. thanks in advance!