I think i found an alternative to scanf/fscanf and that is scanf_s.
So I have my inputs working, I dont know if they are saving for later usage however.
[1]- I am currently stuck trying to calculate the base*exp for case 3, I cannot tie in my methods to make it work. I'd like some elaboration in this area of switches.
[2]- I also would like to know how to 'clear' the previous menu, as the current code will keep repeating the menu when returned to main, which is messy; how can i clear/prevent the menu from repeating itself over and over again?
Code:
#include<stdio.h>
#include<conio.h>
int main()
{
int selection = 0;
int base = 1;
int exponent = 1;
printf("\nPower Menu:\n");
printf(" 1. Change Base\n");
printf(" 2. Change Exponent\n");
printf(" 3. Display base raised to exponent\n");
printf(" 4. Exit Program\n");
printf("Option:");
scanf_s("%d", &selection, 4);
switch(selection)
{
case 1:
printf("Enter Base :");
printf("Base = %d\n", base, scanf_s("%d", &base, stdin));
return main();
case 2:
printf("Enter Exponent :");
printf("Exponent = %d\n", exponent, scanf_s("%d", &exponent, stdin));
return main();
case 3:
printf("The Sum is\n");
return main();
case 4:
printf("Exiting Program\n");
return 0;
default:
printf("Invalid Choice\n");
return main();
}
return main();
}