檔案操作(二進位制拷貝)

diaohong5075發表於2019-07-21
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

//typedef unsigned int size_t;

int main()
{
    FILE *p = fopen("./a.txt","r");
    FILE *p1 = fopen("./b.txt","w");
    char buf[10] = {0};
    while(!feof(p))
    {    
        memset(buf,0,sizeof(buf));
        size_t res = fread(buf,sizeof(char),sizeof(buf),p);
        fwrite(buf,sizeof(char),res,p1);
    }
    fclose(p);
    fclose(p1);
    return 0;
}

 

轉載於:https://www.cnblogs.com/wanghao-boke/p/11222805.html

相關文章