|
Re: C Programming Homework Help Needed
I think I need to make this the "Help Pat pass EGR 261" thread.
My problem this time is that a switch statement again.
After the menu displays, the user can enter a selection, but when they hit enter, it just displays a blank line and doesn't leave the switch statement.
Thanks for the continuing help guys.
Code:
int menu_error;
int menu_selection;
do
{
do
{
menu_error = 0;
/* Displays main menu */
printf("Please select from the following options:\n");
printf("(1) Draw a colored shape\n");
printf("(2) Clear graphics window\n");
printf("(3) Exit\n=>");
fflush(stdin);
scanf("%d\n", &menu_selection);
switch(menu_selection)
{
case 1:
draw_shape();
break;
case 2:
clear_graphics();
break;
case 3:
break;
default:
menu_error = 1;
printf("Please enter a selection 1, 2, or 3");
}
}
while(menu_error);
}
while(menu_selection != 3);
__________________
2003-2006: FRC Team 67 - Drafter, Driver, Student Leader
2006 Volunteering: Kettering Kickoff Ref, Team Ford FIRST Robotics Invitational Ref
2007 Volunteering: GLR Field Reset/Repair; WMR Robot Inspector and Scorekeeper; MARC Referee
2008 Volunteering: WMR Planning Committee, WMR Scorekeeper, MARC Ref, IRI Scorekeeping, WMRI Scorekeeping & DJ
2009 Volunteering: Kettering District, MARC, IRI, and WMRI Scorekeeper/Field Power Controller
2010 Volunteering: Kettering District, MARC, IRI, and WMRI Scorekeeper/Field Power Controller
2011 Volunteering: Waterford District, West Michigan District, MARC, & IRI DJ
2012 Volunteering: Waterford District, West Michigan District DJ
|