zoukankan      html  css  js  c++  java
  • C代码

    #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: ");
        scanf_s("%s", file_name1);
        printf("input the name of the second file: ");
        scanf_s("%s", file_name2);
        printf("input the name of the append file: ");
        scanf_s("%s", file_name_append);

        if (!(file_pointer1 = fopen(file_name1, "rb")))        //分别打开三个文件
        {
            printf("Cannot open the file:%s ", file_name1);
            exit(0);
        }
        if (!(file_pointer2 = fopen(file_name2, "rb")))
        {
            printf("Cannot open the file:%s ", file_name2);
            exit(0);
        }
        if (!(file_pointer2 = fopen(file_name2, "wb")))
        {
            printf("Cannot open the file:%s ", 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");
    }

  • 相关阅读:
    java利用Scanner获取键盘输入
    实验四:数据类型与运算符 4、运算符及表达式实训
    实验三:数据类型与运算符 4、运算符及表达式实训
    Java运算符优先级
    laravel jobs 进程
    安装laravel horizon进程管理
    layui导出表格
    layui无限级分类
    Linux中基本命令
    gogs git 部署服务端钩子 自动发布项目
  • 原文地址:https://www.cnblogs.com/zhangyongjian/p/3617574.html
Copyright © 2011-2022 走看看