thanks ^.^ that woulda caught me up in the future. how can i create a net to catch a letter input and return the error message? what i have up there seems to be the simplest way, but it doesnt work >.< i get a infinite loop
You have an amazing computer right there. Your program should crash.
scanf("%i", &choice); /* missing the & */
But forget all together scanf for picking characters. Too many problems with the extra left in the standard buffer stream.
Use fgets().
char choice[3];
do
{
if ( fgets( choice, sizeof choice, stdin ) )
{
if ( choice[1] != '\n' )
{
while ( getchar() != '\n' );
}
switch (choice[0])
{
case '1':
puts( "You chose 1" );
break;
case '2':
break;
default:
printf("Your choice is invalid, please try again.\n");
break;
}
}
}while(choice[0] != '2');