求助!while中的switch问题,望解惑。
这是我编的题目其中的一段#include <stdio.h>
int main(void)
{
char kind;
int mark=0;
float a_pounds,b_pounds,c_pounds,allpounds,total,o_cost,pl_price;
a_pounds=b_pounds=c_pounds=allpounds=pl_price=0;
printf("Choose the vagetable you want to buy:\n");
printf("a.artichoke. b.beet.\n");
printf("c.carrot. q.quit.\n");
while(scanf("%c",&kind))
{
switch(kind)
{
case'a':printf("Enter the pounds:\n");
scanf("%f",&a_pounds);
break;
case'b':printf("Enter the pounds:\n");
scanf("%f",&b_pounds);
break;
case'c':printf("Enter the pounds:\n");
scanf("%f",&c_pounds);
break;
case'q':mark=1;
break;
}
if(mark)
break;
printf("Choose another vagetable:\n");
}
执行时为什么“Choose another vagetable:”这句话会输出两遍呢?实在不懂。
麻烦知道的解释一下,万分感谢!