关于 switch 函数的用法,新手求教

代码如下:

#include 
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;
}


你可能感兴趣的:(关于 switch 函数的用法,新手求教)