skipping switch statement
Greetings,
I am having a problem with a function skipping over my switch statement and going right to the default. I have a getchar() statement but it rolls right through. Can anyone tell me why? Here is the function
Code:
char choice_selection;
choice_selection = getchar();
switch(choice_selection)
{
case ('A'):
{
int c_choice;
char c_Col_line[100];
printf("How Much? \n");
fgets(c_Col_line, sizeof(c_Col_line), stdin);
sscanf(c_Col_line, "%d", &c_choice);
if(c_choice*c_price > *my_money_ptr)
{
printf("You don't have enough Money!\n");
printf("Please try again.....\n");
//goto start_buy;
}
else
{
*my_money_ptr = (*my_money_ptr - (c_choice*c_price));
*my_c_units_ptr = c_choice;
}
}
case ('B'):
{
int h_choice;
char h_Col_line[100];
printf("How Much? \n");
fgets(h_Col_line, sizeof(h_Col_line), stdin);
sscanf(h_Col_line, "%d", &h_choice);
if(h_choice*h_price > *my_money_ptr)
{
printf("You don't have enough Money!\n");
printf("Please try again.....\n");
//goto start_buy;
}
else
{
*my_money_ptr = (*my_money_ptr - (h_choice * h_price));
*my_h_units_ptr = h_choice;
}
}
case ('C'):
//goto start_buy;
case ('D'):
//goto start_buy;
case ('E'):
//goto start_buy;
case ('F'):
//goto start_buy;
case ('G'):
//goto start_buy;
default :
//goto start_buy;
printf("Default\n");
/* try again */
}