一个关于case-break的问题
来源:百度知道 编辑:UC知道 时间:2024/06/25 06:26:38
#include "stdafx.h"
#include "stdio.h"
int main()
{
printf(" a ,b ,c");
scanf("%c", &choice);
switch choice
{
case 'a':
printf("you have chosen a");
break;
case 'b':
printf("you have chosen b");
break;
case 'c':
printf("you have chosen c");
break;
}
}
不懂为什么不能执行,哪位高手指点下
#include "stdio.h"
int main()
{
printf(" a ,b ,c");
scanf("%c", &choice);
switch choice
{
case 'a':
printf("you have chosen a");
break;
case 'b':
printf("you have chosen b");
break;
case 'c':
printf("you have chosen c");
break;
}
}
不懂为什么不能执行,哪位高手指点下
choice 未定义 switch语句没写对 #include "stdafx.h" 不需要
改过后
#include "stdio.h"
void main()
{
char choice;
printf(" a ,b ,c\n");
scanf("%c", &choice);
switch (choice)
{
case 'a':
printf("you have chosen a\n");
break;
case 'b':
printf("you have chosen b\n");
break;
case 'c':
printf("you have chosen c\n");
}
}
程序没写全,编译没通过。
int main()
{
char choice; // 变量声明
...
switch (choice)
{
..
}
return 0;
}
没定义choice变量,应该是char choice;另外一般#include "stdio.h"写在"stdafx.h"里面.
现在这些年轻人啊。。都被ASP毒害了吗。。
怎么这么多都是不声明变量就使用了。。