Out of all the possible problems I though I may have in my program, this was not one of them.
My menu code is looping twice before stopping for the fgets to take input.. so my menu options are getting printed twice? I have tried flushing the crap out of the stdin, and so many other things.. but it still steps through the same.
So how do I get it to stop this double looping?
Here is a snippet..
void MainMenu()
{
char selection = '\0';
do
{
printf("Bla Bla.. ");
printf("Please make your selection (1, 2, 3 or 4): ");
selection = GetAChar();
switch(selection)
{
...some menu code...
}
}while(selection != '4');
return;
}
char GetAChar()
{
char buffer[CHAR_INPUT]; //CHAR_INPUT is 2
char firstChar = '\0';
(fflush(stdin)); //flush any crap out of stdin
fgets(buffer, CHAR_INPUT, stdin); //readline into string
sscanf(buffer, "%c", &firstChar); // get the first char
return(firstChar);
}
Thanks in advance guys...