永发信息网

求帮忙改一下C语言程序错误

答案:2  悬赏:20  手机版
解决时间 2021-08-20 05:22

#include <stdlib.h>
#include <string.h>
void main()
{void adm2(),build(),search(),modif(),dele();
      adm2();
}
void adm2()
  { char a;
  void window(),clrscr(),gotoxy();
   for(;;)
      { clrscr();
        gotoxy(30,8);printf("built a new user (B)");
        gotoxy(30,10);printf("search car (R)");
        gotoxy(30,12);printf("modif cars (J)");
        gotoxy(30,14);printf("delete user (D)");
        a=getch();
        if(a=='b') build();
        if(a=='r') search();
        if(a=='j') modif();
        if(a=='d') dele();
        else continue;
      }
  }
void build()
  {
 FILE *p;
     char number[20],seat[20],type[2],state[3];
     window(10,10,80,25);
     clrscr();
     printf("请输入车辆牌号:");
     scanf("%s",number);
     printf("seat:");
     scanf("%s",seat);
     printf("type:");
     scanf("%s",type);
     printf("state:");
     scanf("%s",state);
     p=fopen(number,"w+");
     if(p==NULL) { printf("can't build that user");getchar();adm2();}
     fprintf(p,"%s",number);
     fprintf(p,"%s",seat);
     fprintf(p,"%s",type);
     fprintf(p,"%s ",state);
     printf("bulid success");
     getchar();
     fclose(p);
   }
void search()
{
   FILE *fp,*p,*f;
   char type[20],c,number[20],a[5][50];
   int i=0,m,k;   clrscr();
   printf("请输入车辆牌号:");
   scanf("%s",number);
   p=fopen(number,"r");
   if(p==NULL) { printf("error");getchar();fclose(p);exit(0);}
   fscanf(p,"%s",type);
   fclose(p);
   fp=fopen(type,"r");
   do{ fscanf(fp,"%s",a[i++]);       }while(!feof(fp));
   for(k=0;k<i-1;k++) printf("\ncar %d: %s",k+1,a[k]);
   fclose(fp);
   f=fopen(type,"w+");
   for(;;)
   {
   printf("\n\npress the car number that you want to search");
   scanf("%d",&m);
   if(m==7)  { for(k=0;k<i-1;k++)
                 {
                   fprintf(f,"%s\n",a[k]);
                  }
              fclose(f);
              adm2();
            }
   if(m==6) remove(type);
   if(m<6)
    for(k=0;k<i-1;k++)
   { if(k!=m-1)
     fprintf(f,"%s\n",a[k]);
     }
   printf("book %d has returned.",m);
   printf("\ncontinue? (Y/N)");
   c=getchar();
   if(c=='y') continue;
   if(c=='n') { fclose(f);adm2(); }
   }
}
void modif()
   {  FILE *f,*m,*p;
      char type[20],number[20],car[5][50];
      int i=0,n=0,k;
      window(10,10,80,25);clrscr();
      printf("please input the user's number:");
      scanf("%s",number);
      m=fopen(number,"r");
      if(m==NULL) { printf("user no exit"); getchar();fclose(m);adm2();}
      fscanf(m,"%s",type);
      fclose(m);
      p=fopen(type,"r");
      if(p==NULL);
       else
         { while(!feof(p))
         {
          fscanf(p,"%s",car[i]);
          i++;
          }
         i--;
         for(k=0;k<i;k++) printf("\ncar %d :%s",k+1,car[k]);
         }
      fclose(p);
      f=fopen(number,"w");
      printf("\nhow many car do you want to borrow?:");
      do{printf("\ninput:");scanf("%d",&n);  }while(i+n>=6);
      for(k=i;k<i+n;k++)
        { printf("\ncar %d :",k+1);
          scanf("%s",car[k]);
        }
      for(k=0;k<i+n;k++) fprintf(f,"%s\n",car[k]);
      fputc('\0',f);
      printf("success");
      fclose(f);
  }
void dele()
   { FILE  *fp,*f;
     char c,b[5][50],number[20],a[4][20];
     int i=0,j=0,k;
     window(10,10,80,25);clrscr();
     printf("请输入车辆牌号:");
     scanf("%s",number);
     fp=fopen(number,"r");
     if(fp==NULL) { printf("\nuser isn't exit");getchar(); fclose(fp);adm2();}
     else while(!feof(fp))
          { fscanf(fp,"%s",a[i++]);}
     printf("\ntype: %s",a[0]);
     printf("\nnumber: %s",a[1]);
     printf("\nseat: %s",a[2]);
     printf("\nstate: %s",a[3]);
     f=fopen(a[0],"r");
     if(f==NULL);
     else {
           while(!feof(f))
            { fscanf(f,"%s",b[j++]);}
             for(k=0;k<j-1;k++) printf("\ncar %d: %s",k+1,b[k]);
          }
     printf("\nDo you want to delete?  (Y/N): ");
     c=getchar();
     fclose(fp);
     fclose(f);
     if(c=='y') { remove(number);remove(a[0]);printf("\nsuccess");getchar();adm2();}
     if(c=='n') adm2();
    }

实在急用 没分给了  不好意思

最佳答案

void main()
{


void adm2(),//这里不要用VOID


build(),


search(),


modif(),


dele();
    adm2();
}

全部回答

#include <stdlib.h> #include<stdio.h>//少了头文件啊 #include <string.h> #include <conio.h> void main() {void adm2(),build(),search(),modif(),dele();     adm2(); } void adm2()   { char a;   void window(),clrscr(),gotoxy();    for(;;)     { clrscr();     gotoxy(30,8);printf("built a new user (B)");     gotoxy(30,10);printf("search car (R)");     gotoxy(30,12);printf("modif cars (J)");     gotoxy(30,14);printf("delete user (D)");     a=getch();     if(a=='b') build();     if(a=='r') search();     if(a=='j') modif();     if(a=='d') dele();     else continue;     }   } void build()   {  FILE *p;     char number[20],seat[20],type[2],state[3];     window(10,10,80,25);     clrscr();     printf("请输入车辆牌号:");     scanf("%s",number);     printf("seat:");     scanf("%s",seat);     printf("type:");     scanf("%s",type);     printf("state:");     scanf("%s",state);     p=fopen(number,"w+");     if(p==NULL) { printf("can't build that user");getchar();adm2();}     fprintf(p,"%s",number);     fprintf(p,"%s",seat);     fprintf(p,"%s",type);     fprintf(p,"%s ",state);     printf("bulid success");     getchar();     fclose(p);    } void search() {    FILE *fp,*p,*f;    char type[20],c,number[20],a[5][50];    int i=0,m,k;   clrscr();    printf("请输入车辆牌号:");    scanf("%s",number);    p=fopen(number,"r");    if(p==NULL) { printf("error");getchar();fclose(p);exit(0);}    fscanf(p,"%s",type);    fclose(p);    fp=fopen(type,"r");    do{ fscanf(fp,"%s",a[i++]);    }while(!feof(fp));    for(k=0;k<i-1;k++) printf("\ncar %d: %s",k+1,a[k]);    fclose(fp);    f=fopen(type,"w+");    for(;;)    {    printf("\n\npress the car number that you want to search");    scanf("%d",&m);    if(m==7)  { for(k=0;k<i-1;k++)     {     fprintf(f,"%s\n",a[k]);     }     fclose(f);     adm2();     }    if(m==6) remove(type);    if(m<6)     for(k=0;k<i-1;k++)    { if(k!=m-1)     fprintf(f,"%s\n",a[k]);     }    printf("book %d has returned.",m);    printf("\ncontinue? (Y/N)");    c=getchar();    if(c=='y') continue;    if(c=='n') { fclose(f);adm2(); }    } } void modif()    {  FILE *f,*m,*p;     char type[20],number[20],car[5][50];     int i=0,n=0,k;     window(10,10,80,25);clrscr();     printf("please input the user's number:");     scanf("%s",number);     m=fopen(number,"r");     if(m==NULL) { printf("user no exit"); getchar();fclose(m);adm2();}     fscanf(m,"%s",type);     fclose(m);     p=fopen(type,"r");     if(p==NULL);     else     { while(!feof(p))     {     fscanf(p,"%s",car[i]);     i++;     }     i--;     for(k=0;k<i;k++) printf("\ncar %d :%s",k+1,car[k]);     }     fclose(p);     f=fopen(number,"w");     printf("\nhow many car do you want to borrow?:");     do{printf("\ninput:");scanf("%d",&n);  }while(i+n>=6);     for(k=i;k<i+n;k++)     { printf("\ncar %d :",k+1);     scanf("%s",car[k]);     }     for(k=0;k<i+n;k++) fprintf(f,"%s\n",car[k]);     fputc('\0',f);     printf("success");     fclose(f);   } void dele()    { FILE  *fp,*f;     char c,b[5][50],number[20],a[4][20];     int i=0,j=0,k;     window(10,10,80,25);clrscr();     printf("请输入车辆牌号:");     scanf("%s",number);     fp=fopen(number,"r");     if(fp==NULL) { printf("\nuser isn't exit");getchar(); fclose(fp);adm2();}     else while(!feof(fp))     { fscanf(fp,"%s",a[i++]);}     printf("\ntype: %s",a[0]);     printf("\nnumber: %s",a[1]);     printf("\nseat: %s",a[2]);     printf("\nstate: %s",a[3]);     f=fopen(a[0],"r");     if(f==NULL);     else {     while(!feof(f))     { fscanf(f,"%s",b[j++]);}     for(k=0;k<j-1;k++) printf("\ncar %d: %s",k+1,b[k]);     }     printf("\nDo you want to delete?  (Y/N): ");     c=getchar();     fclose(fp);     fclose(f);     if(c=='y') { remove(number);remove(a[0]);printf("\nsuccess");getchar();adm2();}     if(c=='n') adm2();     }

//不过你是在TC就不会报错,但在VC就会报错

我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
右溪记和小石潭记的共同点?
我的兄弟爱上了我马上要追的前女友 怎么办?
小明比小军多18张邮票,小军比小明少1/5,小
为什么李行亮不带牙套?
固始县信阳万家福超市地址在哪里啊
想买个1500左右带操作系统的诺基亚智能手机,
进制转换解题:一个三位数,可以表示为(abc)7或
DNF被封过号的如果装备被清了,还能找得回来吗
什么的晚霞,晚霞是怎么形成的?
A和B是小于100的两个不同自然数,那么A+B/A-B
新娘婚礼致辞,婚礼上新娘爸爸要讲话前主持人
为什么 地球会转不会停下来
身体水分含量过高,人身体中的水分占多少?
卧龙区南阳利民便利店地址在哪,我要去那里
我是一个高中女生,最近老是不禁想到那些男女
推荐资讯
张栋梁为什么歌那么好听,却不怎么红呢?
编制年度生产计划的第一个层次是测算分品种产
笔记本的风扇如何降低杂音
QQ华夏过期了的不死鸟假面如何销毁?
无不有什么成语,带有不什么不什么的成语
这是《陈太丘与友期》
20除√80等于多少
关于永久删除历史记录
谁能告诉涐 - 爱情旳保质期是多久??
物理填空题(我需要解题思路...)
形容翡翠的优美句子,形容女人和翡翠的句子
oppo手机怎么样是
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?