c语言菜单调用不成功为什么,为什么scanf 没有被调用 ??菜单不停的输出??...

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

void main()

{struct LinkQueue q;

Data e;

FILE *fp;

int flag=1,k,i,m;

char c,*menu[]={

"\n1:Creat a Queue and enter the data\n",

"2:Insert a data\n",

"3:Delete a data\n",

"4:Print a List\n",

"5:Save into file\n",

"6:The length of the list\n",

"7:Clear the Queue\n",

"8:The Anv\n",

"9:Destory the Queue\n",

"10:The MAX\n",

"0:Exit\n",

"Select[0-10]:"

};

while(flag){

for(k=0;k<=11;k++)

printf("%s",menu[k]);

scanf("%d",&k);

switch(k){

case 1:

New(&q); break;

case 2:

printf("Where do you want to put the data:\n");

scanf("%d",&m);

printf("Input the data you want to insert:\nNAME:\n");

scanf("%s",&e.name);

printf("XUEHAO:\n");

scanf("%d",&e.grade);

Insert(&q,m,e); break;

case 3:

printf("Input the num of the data you want to delet:\n");

scanf("%d",&i);

Del(&q,i);  break;

case 4:

Out(&q);  break;

case 5:if((fp=fopen("what.txt","wb"))==NULL){

fprintf(stderr,"error:can't creat file what!!!\n");

return;

}

fwrite(&q,sizeof(struct QNode),1,fp);

Save(&q,fp);

fclose(fp);break;

case 6:printf("The length of the list is %d\n",Length(&q));break;

case 7:Clear(&q);break;

case 8:printf("The anverage of the list is %d\n",Anv(&q));break;

case 9:Destory(&q);break;

case 10:printf("The Max data of the list is %d\n",Max(&q));break;

case 0:printf("Save your change??(y/n)");

scanf("%c%*c",&c);

c=='y'||c=='Y'?(c=1):(c=0);

if©{

if((fp=fopen("what.txt","wb"))==NULL) {

fprintf(stderr,"error:can't creat file what!!\n");

return;

}

rewind(fp);

fwrite(&q,sizeof(struct QNode),1,fp);

Save(&q,fp);

fclose(fp);

}

flag=0;

break;

default:

fprintf(stderr,"Select error!!!!!!!\n");

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值