虽然默认部分不能运行, 它运行的情况,我感谢现在所有的帮助,我该怎么办?此代码全部运行我在屏幕默认情况下写入。
do
{
scanf("%c",&choice);
switch(choice)
{
case 'T':
printf("Enter edges of Triangle1\n");
scanf("%d%d",&edge1,&edge2);
Triangle1(edge1,edge2);
break;
case 't':
printf("Enter edges of Triangle1\n");
scanf("%d%d",&edge1,&edge2);
Triangle2(edge1,edge2);
break;
case 'R':
printf("Enter edges of square\n");
scanf("%d%d",&edge1,&edge2);
Rectangle(edge1,edge2);
break;
case 'S':
printf("Enter one edge of square\n");
scanf("%d",&edge);
Square(edge);
break;
case 'C':
printf("Enter radius of circile\n");
scanf("%d",&radius);
Circle(radius);
break;
default:
printf("Wrong input\n");
break;
}//end of switch
printf("\n");
}while(choice!='e');
答案 0 :(得分:1)
新行传递以及输入。尝试在第一个scanf()之后调用“getc(stdin)”,它应该工作:)
查看例如:http://home.datacomm.ch/t_wolf/tw/c/getting_input.html#newline