I want my program to ask me to input #1, 2, or 3 and it will display 1 = Ford, 2=chev, 3=foreign....It executes with no errors of warnings but it stops before it gets to the switch command.
Code:
#include<stdio.h>
main()
{
int n;
printf("Please enter a single digit for a car.\n");
printf("(within the range of 1 to 3):\n");
n=getc(stdin);
switch(n) {
case 1:
printf("Car %d is a Ford.\n",n);
scanf("%d\n",n);
break;
case 2:
printf("Car %d is a Chev.\n",n);
scanf("%d\n",n);
break;
case 3:
printf("Car %d is a Foreign.\n",n);
scanf("%d\n",n);
break;
default:
break;
}
return 0; //Return to the IDE
}
It displays "Please enter a single digit for a car".....you press anything it stops the program. I know its something stupid and small. Any help would be appreciated for this newbie.