#include<stdio.h>


int main(int argc,char *argv[])
{
    FILE *src_fp,*des_fp;
    char buf[128]={0};

    if(argc != 3)
    {
        printf("please input parameter\n");
        return -1;
    }
    
    //打开源文件
    src_fp = fopen(argv[1],"r");
    if(src_fp == NULL)
    {
        printf("open the file %s is failure\n",argv[1]);
        return -1;
    }
    printf("open the file %s is success\n",argv[1]);

    //打开目的文件
    des_fp = fopen(argv[2],"w");
    if(des_fp == NULL)
    {
        printf("open the file %s is failure\n",argv[2]);
        return -2;
    }
    printf("open the file %s is success\n",argv[2]);

    //将源文件拷到目的文件中
    while(1)
    {
        fgets(buf,128,src_fp);
        if(feof(src_fp))
        {
            printf("the file is end\n");
            break;
        }
        fputs(buf,des_fp);
    }

    //关闭文件流
    fclose(src_fp);
    fclose(des_fp);
    return 0;
}

 

相关文章:

  • 2021-12-07
  • 2021-10-06
  • 2021-12-07
  • 2021-05-23
  • 2021-07-04
  • 2022-01-18
猜你喜欢
  • 2021-12-05
  • 2022-02-08
  • 2022-03-03
  • 2021-09-27
  • 2021-09-16
  • 2021-10-25
  • 2021-05-31
相关资源
相似解决方案