全部问题 > 当前问题

switch语句内容,到底是哪里错了呢?

switch(month)

{

case 2:

days = 28;break;

case 4 :csae  6:case  9:case 11:

days = 30;break;

default:

days =31;break;

}

prntf("%d天\n", days)

提示:

--------------------Configuration: HN2 - Win32 Debug--------------------

Compiling...

HN2.c

c:\users\1\desktop\c语言学习\hn2.c(1) : error C2059: syntax error : 'switch'

c:\users\1\desktop\c语言学习\hn2.c(10) : error C2143: syntax error : missing ')' before 'string'

c:\users\1\desktop\c语言学习\hn2.c(10) : error C2143: syntax error : missing '{' before 'string'

c:\users\1\desktop\c语言学习\hn2.c(10) : error C2059: syntax error : '<Unknown>'

c:\users\1\desktop\c语言学习\hn2.c(10) : error C2059: syntax error : ')'

执行 cl.exe 时出错.


HN2.obj - 1 error(s), 0 warning(s


黄庭浩 2018-12-1 11:20:42

共 4 个回答

【C语言】桦桦 2018-12-2 17:07:16

你前面有没有

#include 
int main()
{
   int month,day;
   scanf("%d",&month);
这个,要是有的话,不是语句的问题,应该是中英文符号转化,
c:\users\1\desktop\c语言学习\hn2.c(1) : error C2059: syntax error : 'switch'
c:\users\1\desktop\c语言学习\hn2.c(10) : error C2143: syntax error : missing ')' before 'string'
c:\users\1\desktop\c语言学习\hn2.c(10) : error C2143: syntax error : missing '{' before 'string'
c:\users\1\desktop\c语言学习\hn2.c(10) : error C2059: syntax error : '<Unknown>'
c:\users\1\desktop\c语言学习\hn2.c(10) : error C2059: syntax error : ')'
执行 cl.exe 时出错.

HN2.obj - 1 error(s), 0 warning(s

上面这些是错误,你在上面几行中选中其中一行,双击就找到错误地方了

黄庭浩 2018-12-2 18:51:57

回复 【C语言】桦桦

#include 
int main()
{
   int month,day;
   scanf("%d",&month)

加这个?不行呀.....

【C语言】桦桦 2018-12-3 21:01:20

回复 黄庭浩:把你全部的代码复制过来我瞅瞅

【C语言】桦桦 2019-2-3 18:13:39

回复 :少了头文件

问题来自: switch语句