link.c

来自「大一时课程设计 通信录管理系统 可作为C课程设计的参考」· C语言 代码 · 共 39 行

C
39
字号
#include"yy.h"

void link_files(void)
{
    FILE *fp1,*fp2;
    NODE *p;
    char filename1[20],filename2[20];
    int num=0;

    clrscr();
    printf("\n\n\nPlease input the file name that you want to load:\n");
    printf("(press enter and use 'file1')\n");
    gets(filename1);
    if(strlen(filename1)==0)strcpy(filename1,"file1");
    if((fp1=fopen(filename1,"ab"))==NULL)
        {printf("can not open the file!\nplease choose again\n");
         return;
         }

    printf("Please input the other file that you want to link:\n");
    gets(filename2);
    if((fp2=fopen(filename2,"rb"))==NULL)
        {printf("can not open the file!\nplease choose again\n");
         return;
         }

    p=(NODE *)malloc(LEN);
    while(1)
    {
        if(1!=fread(p,LEN,1,fp2))break;
        if(feof(fp2)!=0)break;
        fwrite(p,LEN,1,fp1);
        num++;
     }
    fclose(fp1);
    fclose(fp2);
    printf("\t add %d records\n",num);
}

⌨️ 快捷键说明

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