语法问题怎么改?????
syntax error : 'while'语法问题怎么改?????
/*上海大众汽车管理系统*/ #include <stdio.h> /*编译预处理—文件包含(标准输入/输出函数)*/ #include <stdlib.h> /*编译预处理—文件包含(常用函数)*/ #include <string.h> /*编译预处理—文件包含(字符串处理函数)*/ #include <conio.h> typedef struct { char ID[10]; /*车辆编号*/ char name[20]; /*车辆名称*/ char type; /*车辆类型*/ char colour[20]; /*车辆颜色*/ float count; /*车辆数量*/ float price; /*车辆价格*/ char beizhu[20]; /*车辆备注*/ }CARS; /*函数声明部分*/ void Delect(); void Correct(); void insert(); void Display(); void Displaysingle(); int SearchByname(); int SearchByIndex(); CARS cars[100]; int num=0; int SearchByIndex(char id[]) /*按车辆编号查询*/ { int i; for (i=0;i<num;i++) { if (strcmp(cars[i].ID,id)==0) /*字符串比较函数*/ { return i; } } return -1; } int SearchByname(char name[]) /*按车辆名称查询*/ { int i; for (i=0;i<num;i++) { if(strcmp(cars[i].name,name)==0) /*字符串比较函数*/ { return i; } } return -1; } void DisplaySingle(int index) /*显示单个汽车信息*/ { printf("%10s%10s%10s%10s%10%10s%10s\n","车辆编号","车辆名称","车辆类别","车辆颜色","车辆价格","车辆备注"); printf("---------------------------------------------------------------------------\n"); printf("%10s%10s%10s%10s%8.2f%8.2f%10s\n",cars[index].ID,cars[index].name,cars[index].type,cars[index].colour,cars[index].count,cars[index].price,cars[index].beizhu); } void Insert() /*插入信息*/ { while(1) { printf("\n\t*请输入车辆编号:"); scanf("%s",&cars[num].ID); getchar(); printf("\n\t 请输入车辆名字:"); scanf("%s",&cars[num].name); getchar(); printf("\n\t 请输入车辆类型:"); scanf("%s",&cars[num].type); getchar(); printf("\n\t 请输入车辆颜色:"); scanf("%s",&cars[num].colour); getchar(); printf("\n\t 请输入车辆数量:"); scanf("%f",&cars[num].count); getchar(); printf("\n\t 请输入车辆价格:"); scanf("%f",&cars[num].price); getchar(); printf("\n\t 请输入车辆备注:"); scanf("%s",&cars[num].beizhu); getchar(); printf("\n ………………………………………………………………………\n"); num++; printf("是否继续?(y/n)"); if(getchar()=='n') { break; printf("\tPlease press any key to menu:"); } } } void Correct() /*修改车辆信息*/ { while(1); { char id[20]; int index; system("cls"); printf("请输入要修改的车辆编号:"); scanf("%s",&id); getchar(); index=SearchByIndex(id); if (index==-1) { printf("该车辆不存在!\n"); } else { printf("你要修改的车辆信息为:\n"); DisplaySingle(index); printf("--请输入新值--\n"); printf(" 输入修改后的车辆编号:"); scanf("%s",&cars[index].ID); printf("\n 输入修改后的车辆名称:"); scanf("%s",&cars[index].name); getchar(); printf("\n 输入修改后的车辆类型:"); scanf("%s",&cars[index].type); getchar(); printf("\n 输入修改后的车辆颜色:"); scanf("%s",&cars[index].colour); getchar(); printf("\n 输入修改后的车辆数量:"); scanf("%f",&cars[index].count); getchar(); printf("\n 输入修改后的车辆价格:"); scanf("%f",&cars[index].price); getchar(); printf("\n 输入修改后的车辆备注:"); scanf("%s",&cars[index].beizhu); getchar(); } printf("是否继续?(y/n)"); if (getchar()=='n') { printf("\tPlease press any key to menu:"); } } } void Delete() /*删除车辆信息*/ { int i; while(1) { char id[20]; int index; printf("请输入要删除的车辆编号:"); getchar(); index=SearchByIndex(id); if (index==-1) { printf("该车辆不存在!\n"); } else { printf("你要删除的车辆信息为:\n"); DisplaySingle(index); printf("是否真的要删除?(y/n)"); if (getchar()=='y') { for (i=index;i<num-1;i++) { cars[i]=cars[i+1]; } num--; } getchar(); } printf("是否继续?(y/n)"); if (getchar()=='n') { break; printf("\tPlease press any key to menu:"); } } } void SelectByName() /*按车辆名称查询*/ { while(1) { char name[20]; int index; printf("请输入要查询的车辆名称:"); scanf("%s",&name); getchar(); index=SearchByname(name); if (index==-1) { printf("该车辆不存在!\n"); } else { printf("你要查询的车辆信息为:\n"); DisplaySingle(index); } printf("是否继续?(y/n)"); if (getchar()=='n') { break; printf("\tPlease press any key to menu:"); } } } void SelectByIndex() /*按车辆编号查询*/ { while(1) { char id[20]; int index; printf("请输入要查询的车辆编号:"); scanf("%s",id); index=SearchByIndex(id); if(index==-1) { printf("该车辆不存在!\n"); } else { printf("你要查询的车辆信息为:\n"); DisplaySingle(index); } printf("是否继续?(y/n)"); flushall(); if (getchar()=='n') { break; printf("\tPlease press any key to menu:"); } } } void Sort() /*按车辆编号排序*/ { int i,j; CARS temp ; for (i=0;i<num;i++) { for (j=1;j<num-i;j++) { if (cars[j-1].ID<cars[j].ID) { temp=cars[j-1]; cars[j-1]=cars[j]; cars[j]=temp; } } } } void Display() { int i; printf("%10s%10s%10s%10s%10%10s%10s\n","车辆编号","车辆名称","车辆类别","车辆颜色","车辆价格","车辆备注"); printf("---------------------------------------------------------------------------\n"); for (i=0;i<num;i++) { printf("%10s%10s%10s%10s%8.2f%8.2f%10s\n",cars[i].ID,cars[i].name,cars[i].type,cars[i].colour,cars[i].count,cars[i].price,cars[i].beizhu); } } void Read() /*读取信息*/ { FILE *fp; /*定义文件指针*/ int i; if ((fp=fopen("cars_list.txt","rb"))==NULL) { printf("不能打开文件!\n"); return; } if (fread(&num,sizeof(cars),1,fp)!=1) { num=-1; } else { for(i=0;i<num;i++) { fread(&cars[i],sizeof(cars),1,fp); } } fclose(fp); } void Write() /*写入信息*/ { FILE *fp; /*定义文件指针*/ int i; if ((fp=fopen("cars_list.txt","wb"))==NULL) { printf("不能打开文件!\n"); return; } if (fwrite(&num,sizeof(cars),1,fp)!=1) { printf("写入文件错误!\n"); } for (i=0;i<num;i++) { if (fwrite(&cars[i],sizeof(cars),1,fp)!=1) { printf("写入文件错误!\n"); } } fclose(fp); } int main() { char key[6]; system("cls"); printf("\n *************************************************************\n *\t\t\t\t\t\t\t\t *\n"); printf(" * ▏▎▍ ▌ ▋ ▊ █ ▇ ▆ ▅ ▄ ▃ ▂ ▁ *"); printf("\n ☆★☆★☆★☆欢迎进入上海大众汽车管理系统☆★☆★☆★☆ \n"); printf(" 密码: "); scanf("%s",key); if(strcmp(key,"12345")==0) { printf("\n欢迎光临\n"); printf("\n*************************************************************\n *\t\t\t\t\t\t\t\t *\n"); printf(" * ▏▎▍ ▌ ▋ ▊ █ ▇ ▆ ▅ ▄ ▃ ▂ ▁ *"); getch(); Read(); } else { printf("\n\n\n\n Error 密码输入错误!\n\n\n\n"); printf(" 请重新输入密码:"); } while(1) { int choice; printf("\n\n--★-☆--★-☆--☆-★--☆-★--☆-☆--★-\n"); printf("\n\t\t\t 上海大众汽车管理系统\t\n\n"); printf("\t 1 →显示汽车信息\n\n"); printf("\t 2 →增加汽车信息\n\n"); printf("\t 3 →删除汽车信息\n\n"); printf("\t 4 →更新汽车信息\n\n"); printf("\t 5 →按车辆编号查询信息\n\n"); printf("\t 6 →按车辆名称查询汽车信息\n\n"); printf("\t 7 →按编号排序汽车信息\n\n"); printf(" \t\t --☆-★--☆-★--☆-☆--★-☆--★-☆--★-");/*菜单选择界面*/ printf("\n\n"); printf("\t请选择您所要的操作(或选择(0)退出):"); scanf("%d",&choice); getchar(); switch(choice) { case 1:Display();break; case 2:Insert();break; case 3:Delete();break; case 4: Correct();break; case 5:SelectByIndex();break; case 6:SelectByName();break; case 7:Sort(); Display();break; case 0: printf("欢迎使用!!!!谢谢再见!!!!");return 0; /*退出系统*/ } Write(); } }