load.c

来自「学生信息查询系统C语言实现 包含的功能有: 1、 系统功能选择菜单:提供了5」· C语言 代码 · 共 54 行

C
54
字号
/*导入原始数据*/
void load()
{
 int i;    /*循环变量*/
 char file[30];  /*文件的路径名*/
 FILE *fp;     /*文件指针*/

 while(1)
      {
       clrscr();

       for(i=13;i<=67;i++)
          {
           gotoxy(i,5);
	   printf("%c",006);
           gotoxy(i,20);
	   printf("%c",006);
          }

       gotoxy(15,8);
       printf("Please intput the path of the file:");
       gotoxy(15,10);
       scanf("%s",&file);       /*输入文件路径名*/

       fp=fopen(file,"rb");   /*读取文件*/

       if(fp==NULL)    /*文件导入出错*/
         {
          gotoxy(15,12);
          printf("Can not open the file!\n");
          gotoxy(15,14);
          printf("Press any key to giving the right path...");
	  getch();
          continue;
         }

        for(i=0;i<Maxsize;i++)
	  if(fread(&student[i],SIZE,1,fp)!=1)
	    {
	     k=i;            /*获取文件中记录的个数*/
	     if(feof(fp))    /*文件结束*/
	       {
		 fclose(fp);
		 return;
	       }
	     gotoxy(15,12);
             printf("File read error\n");
             getch();
            }

       fclose(fp);   /*关闭文件*/
       return;
      }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?