switch(estate){
中 的estate的值你赋值了吗
--------------------------
我不知道你的源程序是啥样的,我写了给main函数,在我的机器中运行成功!(你的语法是对的)
我的打印结果是:
--------------
空闲
1
2
-----------------------
我的代码如下:
#include
void main(void)
{
FILE * cfPtr; //定义指向存储请求和输出电梯运行结果的文件指针
int estate =0;
int current=1;
int next =2;
if((cfPtr=fopen("f:/result.txt","w"))==NULL)
printf("File cannot be opened.\n");
else
switch(estate){
case 0: fprintf(cfPtr,"空闲\n"); break;
case 1: fprintf(cfPtr,"运行\n"); break;
case 2: fprintf(cfPtr,"停靠\n"); break;
default: fprintf(cfPtr,"cuole");
} //switch,
fprintf(cfPtr," %d\n %d\n\n",current,next);
fflush(cfPtr);
}
好像没有 fprintf吧,用print