这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » STM32 » 标准块CP功能实现

共2条 1/1 1 跳转至

标准块CP功能实现

高工
2018-04-26 13:41:31     打赏
#include<stdio.h>int main(int argc,char *argv[])
{
    FILE *src_fp,*des_fp;    int src_ret;    char buf[128]={0};    if(argc != 3)
    {
        printf("please input paramester\n");        return -1;
    }    //打开源文件
    src_fp = fopen(argv[1],"r");    if(src_fp == NULL)
    {
        printf("open the file %s is failure\n",argv[1]);        return -2;
    }
    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 -3;
    }
    printf("open the File %s is success\n",argv[2]);    //将源文件拷到目的文件中
    while(1)
    {
        src_ret = fread(buf,1,128,src_fp);        if(src_ret == 0)
        {
            printf("the file is end\n");            break;
        }
        fwrite(buf,1,src_ret,des_fp);
    }    //关闭文件流    fclose(src_fp);
    fclose(des_fp);    return 0;
}
复制代码

 




管理员
2018-04-27 07:40:21     打赏
2楼

谢谢楼主分享


共2条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]