联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> C/C++编程C/C++编程

日期:2018-08-29 10:11

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#include "functions草稿.h"


int main()

{

   ZGDAGLXT da[N];      //da=档案

   FILE *fp;

   int select;

   char ch;

   int count=0;


   fp=fopen ("D:\\record","ab+"); //,a表追加,b表二进制  // ()中调用D盘上record文件

   if (fp==NULL)

   {

       printf("\n====>can not open file!\n");//fopen函数用来检测流上的文件结束符,若结束返回非0,or 0

   exit (0);

}

while (!feof (fp))  //将职工的信息读取到内存中,保存在da数组里)

{

   if(fread(&da[count],sizeof(ZGDAGLXT),1,fp)==1)//读文件,从fp处 开始以一个数据单元从ZGDAGL中读,放到count(记录数)中

       count++;

}

fclose (fp);

printf("\n====>open file sucess,the total number is:%d\n,"count);

printf("\n\n\n Press any key to continue.");

getchar();  //接受回车

mune();    //快速闪过

while(1)

{

   system("cls");

   mune();

   printf("\n\t\t\t Please enter your choise (0~8):");

   scanf("%d",&select);

   if(select==0)

   {

       if(saveflag==1)//记录数据是否进行修改,1修改

       {

           getchar();

           printf("\n==>Whether save the modified record to the file?(y/n):");

           scanf("%c",&ch);

           if(ch=='y'||ch=='Y')

               Savefile(da,count);

       }

       printf("\n==>Thank you for your useness!");

       getchar();

       break;//跳到while(1)

   }

   switch(select)

   {

     case 1: count=Add(da,count);break;     //增加

     case 2: count=Del(da,count);break;     //删除

     case 3: Query(da,count);break;         //查找

     case 4: Modify(da,count);break;        //修改

     case 5: count = Insert(da,count);break;//插入

     case 6: Sort(da,count);break;          //排序

     case 7: SaveFile(da,count);break;      //储存

     case 8: {system("cls");             //显示

                    Disp(da,count);//disp是显示函数

                    printf("Press any key to continue.");

                    getchar();break;

             };

           default: Wrong();getchar();break;

    }

}//对应while(1)

 return 0;

}



版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp