Hi, I was wondering if I could get some advise.
This is just a small part of the code.
When the user inputs the wrong data, he is prompted to enter the correct data, but the only problem is that the program ends and the user has to start all over.
Is there a way I could get the user back to the beginning, where the user is prompted to enter two hex numbers without the program ending.
Thanks
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int main(int argc, char *argv[])
{
int reply;
puts("\n****************************************** ******************");
puts("\nEnter a menu number selection between 1 and 4, 0 to exit: ");
puts("\n****************************************** ******************");
scanf("%d", &reply);
switch (reply)
{
case 0:
exit(0);
case 1:
{
int a, b, c, r;
printf ("Two numbers please.\n");
r = scanf ("%x%x", &a, &b);
if ( r == 2 )
{
c = a + b;
printf ("%#x", c);
}
else
printf("hex please");
break;
}
default:
puts("Between 1 and 4, please!\n");
} /* end of switch */
return 0;
}