Hey guys my while condition isnt working working properly in validateMonth what happens it just stays in there. If i type in 5 or any number between 0-12 it will still say its the wrong input. Why isnt it testing the condition properly?
Code:
unsigned getMonth()
{
/*** declare variables*/
unsigned tmpMonth;
int valid = 0;
char *prompt = "Please enter a month between 0 - 12 !\n";
char *month;
unsigned valMonth;
month = getUserInput(prompt);
tmpMonth = validateMonth(valMonth, prompt);
return EXIT_SUCCESS;
}
Code:
unsigned validateMonth(unsigned month, char *prompt)
{
unsigned m;
int flag = FALSE; /* false value*/
do
{
while(flag == TRUE || month<0 || month>12) /* flag 1 for true*/
{
flag = FALSE;
printf("Month error 0 or less or equal to 12 please\n");
getUserInput(prompt);
}
}while(flag !=FALSE);
return m;
}