首页 > 代码库 > c语言拷贝文件程序
c语言拷贝文件程序
#include <stdio.h> #include <stdlib.h> #include <string.h> #define SIZE 1024*1024*10 int main() { FILE *fp_read, *fp_write; fp_read = fopen("E:\\CentOS-6.5\\CentOS-6.5-i386-bin-DVD1.iso","rb"); fp_write = fopen("D:\\CentOS-6.5-i386-bin-DVD1.iso","wb"); char *buf; int read_n, write_n; buf = (char*)calloc(1,SIZE); if (fp_read == NULL || fp_write == NULL){ perror("File open fail.\n"); } printf("开始拷贝 %s:\n","pycharm-professional-3.1.3.exe"); while (memset(buf, 0, SIZE), (read_n = fread(buf, 1, SIZE, fp_read)) > 0){ write_n = fwrite(buf, 1, read_n, fp_write); if (write_n != read_n){ printf("write error\n"); system("pause"); exit(-1); } } printf("%s 拷贝成功.\n","pycharm-professional-3.1.3.exe"); fclose(fp_read); fclose(fp_write); }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。