首页 > 其他 > 详细

C代码

时间:2014-03-22 19:08:08      阅读:441      评论:0      收藏:0      [点我收藏+]

#include<stdio.h>
#include<stdlib.h>

void main()
{
    char    ch, file_name1[20], file_name2[20], file_name_append[20];
    FILE    *file_pointer1, *file_pointer2, *file_pointer_append;

    printf("input the name of the first file:\n");
    scanf_s("%s", file_name1);
    printf("input the name of the second file:\n");
    scanf_s("%s", file_name2);
    printf("input the name of the append file:\n");
    scanf_s("%s", file_name_append);

    if (!(file_pointer1 = fopen(file_name1, "rb")))        //分别打开三个文件
    {
        printf("Cannot open the file:%s\n", file_name1);
        exit(0);
    }
    if (!(file_pointer2 = fopen(file_name2, "rb")))
    {
        printf("Cannot open the file:%s\n", file_name2);
        exit(0);
    }
    if (!(file_pointer2 = fopen(file_name2, "wb")))
    {
        printf("Cannot open the file:%s\n", file_name_append);
        exit(0);
    }

    while (!(feof(file_pointer1)))        //将file1和file2写到file_append中去
    {
        ch = fgetc(file_pointer1);
        fputc(ch, file_pointer_append);
    }
    fclose(file_pointer1);
    while (!(feof(file_pointer2)))
    {
        ch = fgetc(file_pointer2);
        fputc(ch, file_pointer_append);
    }
    fclose(file_pointer2);
    fclose(file_pointer_append);
    system("pause");
}

C代码,布布扣,bubuko.com

C代码

原文:http://www.cnblogs.com/zhangyongjian/p/3617574.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!