user-0 提问: c语言毕业设计改正，

回复:
user: user-0
content: 引用 3 楼 自信男孩的回复:#include<stdio.h> #include<stdlib.h> #include<string.h>  struct tushu {     char bianhao1[10];     char bianhao2[10];     char leixing[20];     char shuming[50];     char chubanshe[50];     char writer[20];     long zongshu;     long shengyu; }shu;  struct shops {     char bianhao1[10];     char bianhao2[10];     long nian; }book;  struct tushu tu[1000];  void shan() {     FILE *fp;     int i=0,j,n,m,l;     char shopnum[20];     if((fp=fopen("tushu.txt","r"))==NULL)     {         printf("can not open the pingjia.txt.\n");         exit(0);     }     while(fread(&tu[i],sizeof(shu),1,fp))     {         i++;         m=i;     }     printf("要删除哪几个评价：");     scanf("%d",&n);     getchar();     for(i=0;i<n;i++)     {         printf("输入评价编号2：");         fgets(shopnum, 20, stdin);         for(j=0;j<m;j++)             if(strcmp(shopnum,tu[j].bianhao2)==0)                 break;         if(j<m)         {             for(l=0;l<m;l++)                 if(strcmp(tu[j].bianhao1,tu[l].bianhao1)==0)                 {                     tu[l].zongshu--;                     tu[l].shengyu--;                 }             for(;j<m;j++)                 tu[j]=tu[j+1];         }         else         {             printf("输入有误  重新输入\n");             i--;         }     }     if((fp=fopen("tushu.txt","w"))==NULL)     {         printf("can not open the tushu.txt.\n");         exit(0);     }     for(i=0;i<m-n;i++)         fwrite(&tu[i],sizeof(shu),1,fp);     printf("删除成功！！"); } void xiu()                                        //修改评价信息 {     FILE *fp;     int i=0,m,n;     char shopnum[20],numchar[20];     struct tushu tu[1000];     if((fp=fopen("tushu.txt","r"))==NULL)     {         printf("can not open the borrow.txt.\n");         exit(0);     }     while(fread(&tu[i],sizeof(shu),1,fp))     {         i++;         m=i;     }     if((fp=fopen("tushu.txt","w"))==NULL)     {         printf("can not open the borrow.txt.\n");         exit(0);     }     printf("要修改哪几个评价:");     scanf("%d",&n);     getchar();     for(i=0;i<n;i++)     {         printf("输入要修改的评价编号2：");         fgets(shopnum, 20, stdin);         for(i=0;i<m;i++)         {             if(strcmp(shopnum,tu[i].bianhao2)==0)                 break;         }         if(i<m)         {             printf("》》》输入修改后的\n\n");             printf("》》》输入编号1:");             fgets(tu[i].bianhao1, 10, stdin);             printf("\n");             printf("》》》编号2:");             fgets(tu[i].bianhao2, 10, stdin);             printf("\n");             printf("》》》类型:");             fgets(tu[i].leixing, 20, stdin);             printf("\n");             printf("》》》店铺名字:");             fgets(tu[i].shuming, 50, stdin);             printf("\n");             printf("》》》评价详情:");             fgets(tu[i].chubanshe, 50, stdin);             printf("\n");             printf("》》》评分:");             fgets(tu[i].writer, 20, stdin);             printf("\n");             printf("》》》消费金额:");             fgets(numchar, 20, stdin);             printf("\n");             tu[i].zongshu=atol(numchar);             printf("》》》购物次数:");             fgets(numchar, 20, stdin);             printf("\n");             tu[i].shengyu=atol(numchar);         }         else             printf("输入有误\n");         for(i=0;i<m;i++)             fwrite(&tu[i],sizeof(shu),1,fp);     }     fclose(fp); } void putin()                                               //录入评价 {     char numchar[20];     FILE *fp;     int i=0,m,n;     struct tushu tu[1000];     if((fp=fopen("tushu.txt","r"))==NULL)     {         printf("can not open the borrow.txt.\n");         exit(0);     }     while(fread(&tu[i],sizeof(shu),1,fp))     {         i++;         m=i;     }     if((fp=fopen("tushu.txt","w"))==NULL)     {         printf("can not open the borrow.txt.\n");         exit(0);     }     for(i=0;i<m;i++)     {         fwrite(&tu[i],sizeof(shu),1,fp);     }     printf("要录入几条评价：");     scanf("%d",&n);     getchar();     for(i=0;i<n;i++)     {         printf("\n");         printf("》》》输入编号1:");         fgets(tu[i].bianhao1, 10, stdin);         printf("\n");         printf("》》》编号2:");         fgets(tu[i].bianhao2, 10, stdin);         printf("\n");         printf("》》》类型:");         fgets(tu[i].leixing, 20, stdin);         printf("\n");         printf("》》》店铺名字:");         fgets(tu[i].shuming, 50, stdin);         printf("\n");         printf("》》》评价详情:");         fgets(tu[i].chubanshe, 50, stdin);         printf("\n");         printf("》》》评分:");         fgets(tu[i].writer, 20, stdin);         printf("\n");         printf("》》》消费金额:");         fgets(numchar, 20, stdin);         printf("\n");         tu[i].zongshu=atol(numchar);         printf("》》》购物次数:");         fgets(numchar, 20, stdin);         printf("\n");         shu.shengyu=atol(numchar);         fwrite(&shu,sizeof(shu),1,fp);     }     fclose(fp); } void print()                                           //打印图书信息表 {     FILE *fp;     if((fp=fopen("tushu.txt","r"))==NULL)     {         printf("can not open the tushu.txt.\n");         exit(0);     }     puts("");     puts("");     puts("| 编号1  | 编号2  |  类型  |  店铺名字  |   评价详情   |   评分  |  消费金额 |   购物次数 |");     fseek(fp,0L,SEEK_SET);     while(fread(&shu,sizeof(shu),1,fp)==1)         printf("  %-9s%-10s%-10s%-10s%-10s%-10s%-10ld%-10ld\n",shu.bianhao1,shu.bianhao2,shu.leixing,shu.shuming,shu.writer,shu.chubanshe,shu.zongshu,shu.shengyu); }  void shops()                                                //创建店铺文件 {     FILE *fp;     int i = 0;     char numchar[50],ch='y';     if((fp=fopen("tushu.txt","wt"))==NULL)     {         printf("can not open the tushu.txt.\n");         exit(0);     }     while(ch=='y'||ch=='Y')     {         printf("\n");         printf("》》》输入编号1:");         fgets(tu[i].bianhao1, 10, stdin);         printf("\n");         printf("》》》编号2:");         fgets(tu[i].bianhao2, 10, stdin);         printf("\n");         printf("》》》类型:");         fgets(tu[i].leixing, 20, stdin);         printf("\n");         printf("》》》店铺名字:");         fgets(tu[i].shuming, 50, stdin);         printf("\n");         printf("》》》评价详情:");         fgets(tu[i].chubanshe, 50, stdin);         printf("\n");         printf("》》》评分:");         fgets(tu[i].writer, 20, stdin);         printf("\n");         printf("》》》消费金额:");         fgets(numchar, 50, stdin);         printf("\n");         tu[i].zongshu=atol(numchar);         printf("》》》购物次数:");         fgets(numchar, 50, stdin);         printf("\n");         shu.shengyu=atol(numchar);         fwrite(&shu,sizeof(shu),1,fp);         do{             printf("have another book record(y/n)?:");             fgets(numchar, 50, stdin);             ch=numchar[0];         }while(!(ch=='y'||ch=='n'||ch=='Y'||ch=='N'));         i++;     }     fclose(fp); }  int main() {     int flag=1;     char a[20];     puts("");     puts("        欢迎使用顾客满意度调查系统系统            ");     puts("                                                   ");     puts("                                                    ");     puts("                                                    ");     puts("           请选择您需要的功能 ：                    ");     puts("          （直接键入对应数字）                      ");     puts("           1.市场选择                               ");     puts("                                                    ");     puts("          2.显示你已评价的商店                     ");     puts("                                                   ");     puts("          3.追评您的评价                           ");     puts("                                                   ");     puts("           4.修改您的评价                           ");     puts("                                                    ");     puts("           5.删除您做过的评价                       ");     puts("                                                  ");      while(flag)     {         flag=0;         scanf("%s",a);         getchar();         if(strcmp(a,"3")==0)             putin();         else if(strcmp(a,"1")==0)             printf("Not support!\n");             //books();         else if(strcmp(a,"2")==0)             print();         else if(strcmp(a,"4")==0)             xiu();         else if(strcmp(a,"5")==0)             shan();         else         {             printf("输入错误   请重新输入：");             flag=1;         }     }      return 0; } 改掉了所有语法错误。 如果自己一窍不通，其实我们给你改了你一样不知道改了什么。建议还是好好学一学，语法是最基本的C语言，所以语法错误是最低级的错误； 谢谢你的建议，我会注意的，谢谢！

user: user-1
content: http://blog.csdn.net/zhao4zhong1/article/details/53078924 老司机找bug的十年心路历程

user: user-2
content: #include<stdio.h> #include<stdlib.h> #include<string.h>  struct tushu {     char bianhao1[10];     char bianhao2[10];     char leixing[20];     char shuming[50];     char chubanshe[50];     char writer[20];     long zongshu;     long shengyu; }shu;  struct shops {     char bianhao1[10];     char bianhao2[10];     long nian; }book;  struct tushu tu[1000];  void shan() {     FILE *fp;     int i=0,j,n,m,l;     char shopnum[20];     if((fp=fopen("tushu.txt","r"))==NULL)     {         printf("can not open the pingjia.txt.\n");         exit(0);     }     while(fread(&tu[i],sizeof(shu),1,fp))     {         i++;         m=i;     }     printf("要删除哪几个评价：");     scanf("%d",&n);     getchar();     for(i=0;i<n;i++)     {         printf("输入评价编号2：");         fgets(shopnum, 20, stdin);         for(j=0;j<m;j++)             if(strcmp(shopnum,tu[j].bianhao2)==0)                 break;         if(j<m)         {             for(l=0;l<m;l++)                 if(strcmp(tu[j].bianhao1,tu[l].bianhao1)==0)                 {                     tu[l].zongshu--;                     tu[l].shengyu--;                 }             for(;j<m;j++)                 tu[j]=tu[j+1];         }         else         {             printf("输入有误  重新输入\n");             i--;         }     }     if((fp=fopen("tushu.txt","w"))==NULL)     {         printf("can not open the tushu.txt.\n");         exit(0);     }     for(i=0;i<m-n;i++)         fwrite(&tu[i],sizeof(shu),1,fp);     printf("删除成功！！"); } void xiu()                                        //修改评价信息 {     FILE *fp;     int i=0,m,n;     char shopnum[20],numchar[20];     struct tushu tu[1000];     if((fp=fopen("tushu.txt","r"))==NULL)     {         printf("can not open the borrow.txt.\n");         exit(0);     }     while(fread(&tu[i],sizeof(shu),1,fp))     {         i++;         m=i;     }     if((fp=fopen("tushu.txt","w"))==NULL)     {         printf("can not open the borrow.txt.\n");         exit(0);     }     printf("要修改哪几个评价:");     scanf("%d",&n);     getchar();     for(i=0;i<n;i++)     {         printf("输入要修改的评价编号2：");         fgets(shopnum, 20, stdin);         for(i=0;i<m;i++)         {             if(strcmp(shopnum,tu[i].bianhao2)==0)                 break;         }         if(i<m)         {             printf("》》》输入修改后的\n\n");             printf("》》》输入编号1:");             fgets(tu[i].bianhao1, 10, stdin);             printf("\n");             printf("》》》编号2:");             fgets(tu[i].bianhao2, 10, stdin);             printf("\n");             printf("》》》类型:");             fgets(tu[i].leixing, 20, stdin);             printf("\n");             printf("》》》店铺名字:");             fgets(tu[i].shuming, 50, stdin);             printf("\n");             printf("》》》评价详情:");             fgets(tu[i].chubanshe, 50, stdin);             printf("\n");             printf("》》》评分:");             fgets(tu[i].writer, 20, stdin);             printf("\n");             printf("》》》消费金额:");             fgets(numchar, 20, stdin);             printf("\n");             tu[i].zongshu=atol(numchar);             printf("》》》购物次数:");             fgets(numchar, 20, stdin);             printf("\n");             tu[i].shengyu=atol(numchar);         }         else             printf("输入有误\n");         for(i=0;i<m;i++)             fwrite(&tu[i],sizeof(shu),1,fp);     }     fclose(fp); } void putin()                                               //录入评价 {     char numchar[20];     FILE *fp;     int i=0,m,n;     struct tushu tu[1000];     if((fp=fopen("tushu.txt","r"))==NULL)     {         printf("can not open the borrow.txt.\n");         exit(0);     }     while(fread(&tu[i],sizeof(shu),1,fp))     {         i++;         m=i;     }     if((fp=fopen("tushu.txt","w"))==NULL)     {         printf("can not open the borrow.txt.\n");         exit(0);     }     for(i=0;i<m;i++)     {         fwrite(&tu[i],sizeof(shu),1,fp);     }     printf("要录入几条评价：");     scanf("%d",&n);     getchar();     for(i=0;i<n;i++)     {         printf("\n");         printf("》》》输入编号1:");         fgets(tu[i].bianhao1, 10, stdin);         printf("\n");         printf("》》》编号2:");         fgets(tu[i].bianhao2, 10, stdin);         printf("\n");         printf("》》》类型:");         fgets(tu[i].leixing, 20, stdin);         printf("\n");         printf("》》》店铺名字:");         fgets(tu[i].shuming, 50, stdin);         printf("\n");         printf("》》》评价详情:");         fgets(tu[i].chubanshe, 50, stdin);         printf("\n");         printf("》》》评分:");         fgets(tu[i].writer, 20, stdin);         printf("\n");         printf("》》》消费金额:");         fgets(numchar, 20, stdin);         printf("\n");         tu[i].zongshu=atol(numchar);         printf("》》》购物次数:");         fgets(numchar, 20, stdin);         printf("\n");         shu.shengyu=atol(numchar);         fwrite(&shu,sizeof(shu),1,fp);     }     fclose(fp); } void print()                                           //打印图书信息表 {     FILE *fp;     if((fp=fopen("tushu.txt","r"))==NULL)     {         printf("can not open the tushu.txt.\n");         exit(0);     }     puts("");     puts("");     puts("| 编号1  | 编号2  |  类型  |  店铺名字  |   评价详情   |   评分  |  消费金额 |   购物次数 |");     fseek(fp,0L,SEEK_SET);     while(fread(&shu,sizeof(shu),1,fp)==1)         printf("  %-9s%-10s%-10s%-10s%-10s%-10s%-10ld%-10ld\n",shu.bianhao1,shu.bianhao2,shu.leixing,shu.shuming,shu.writer,shu.chubanshe,shu.zongshu,shu.shengyu); }  void shops()                                                //创建店铺文件 {     FILE *fp;     int i = 0;     char numchar[50],ch='y';     if((fp=fopen("tushu.txt","wt"))==NULL)     {         printf("can not open the tushu.txt.\n");         exit(0);     }     while(ch=='y'||ch=='Y')     {         printf("\n");         printf("》》》输入编号1:");         fgets(tu[i].bianhao1, 10, stdin);         printf("\n");         printf("》》》编号2:");         fgets(tu[i].bianhao2, 10, stdin);         printf("\n");         printf("》》》类型:");         fgets(tu[i].leixing, 20, stdin);         printf("\n");         printf("》》》店铺名字:");         fgets(tu[i].shuming, 50, stdin);         printf("\n");         printf("》》》评价详情:");         fgets(tu[i].chubanshe, 50, stdin);         printf("\n");         printf("》》》评分:");         fgets(tu[i].writer, 20, stdin);         printf("\n");         printf("》》》消费金额:");         fgets(numchar, 50, stdin);         printf("\n");         tu[i].zongshu=atol(numchar);         printf("》》》购物次数:");         fgets(numchar, 50, stdin);         printf("\n");         shu.shengyu=atol(numchar);         fwrite(&shu,sizeof(shu),1,fp);         do{             printf("have another book record(y/n)?:");             fgets(numchar, 50, stdin);             ch=numchar[0];         }while(!(ch=='y'||ch=='n'||ch=='Y'||ch=='N'));         i++;     }     fclose(fp); }  int main() {     int flag=1;     char a[20];     puts("");     puts("        欢迎使用顾客满意度调查系统系统            ");     puts("                                                   ");     puts("                                                    ");     puts("                                                    ");     puts("           请选择您需要的功能 ：                    ");     puts("          （直接键入对应数字）                      ");     puts("           1.市场选择                               ");     puts("                                                    ");     puts("          2.显示你已评价的商店                     ");     puts("                                                   ");     puts("          3.追评您的评价                           ");     puts("                                                   ");     puts("           4.修改您的评价                           ");     puts("                                                    ");     puts("           5.删除您做过的评价                       ");     puts("                                                  ");      while(flag)     {         flag=0;         scanf("%s",a);         getchar();         if(strcmp(a,"3")==0)             putin();         else if(strcmp(a,"1")==0)             printf("Not support!\n");             //books();         else if(strcmp(a,"2")==0)             print();         else if(strcmp(a,"4")==0)             xiu();         else if(strcmp(a,"5")==0)             shan();         else         {             printf("输入错误   请重新输入：");             flag=1;         }     }      return 0; } 改掉了所有语法错误。 如果自己一窍不通，其实我们给你改了你一样不知道改了什么。建议还是好好学一学，语法是最基本的C语言，所以语法错误是最低级的错误；

user: user-3

user: user-4
content: 看编译器提示，tu，i，books没定义，puts前没有分号