关于 switch 函数的用法,新手求教。。
#include <stdio.h>enum{COPY,START,COMMENT,END};
int main(void)
{
char c;
int state=COPY;
while((c=getchar())!=EOF)
{
switch(state)
case COPY: 这个地方正确
if(c=='/')
state=START;
else
putchar(c);
break;
case START: 错误case label not within a switch statement
if(c=='*')
state=COMMENT;
else
{
putchar('/');
state=(c=='/')?START:(putchar(c),COPY);
}
break;
case COMMENT: 错误case label not within a switch statement
if(c=='*')
state=END;
else
putchar(c);
break;
case END: 错误case label not within a switch statement
if(c=='/')
state=COPY;
else if(c=='*')
state=END;
else
state=COMMENT;
break;
}
return 0;
}
这是为什么???