Switch 语句求助
程序代码:
#include <stdio.h> int main(void) { char c; switch(c=getchar()) {case ('0'<=c && c<='9') : printf("this is a digit\n"); break; case ('a'<=c && c<='z') : printf("this is a small letter\n"); break; case ('A'<=c && c<='Z') : printf("this is a capital letter\n"); break; default : printf("this is the other\n"); } }--------------------Configuration: stu - Win32 Debug-------------------- Compiling... c.c E:\软件\VC6\MyProjects\stu\c.c(6) : error C2051: case expression not constant E:\软件\VC6\MyProjects\stu\c.c(7) : error C2051: case expression not constant E:\软件\VC6\MyProjects\stu\c.c(8) : error C2051: case expression not constant 执行 cl.exe 时出错. c.obj - 1 error(s), 0 warning(s)
Switch语句为什么会出错呢?不明白,望大侠指教!谢谢