码迷,mamicode.com
首页 > 编程语言 > 详细

c语言拷贝文件程序

时间:2014-06-15 08:51:27      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:文件拷贝   fwrite   fread   

#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);
}


c语言拷贝文件程序,布布扣,bubuko.com

c语言拷贝文件程序

标签:文件拷贝   fwrite   fread   

原文地址:http://blog.csdn.net/nyist327/article/details/30460641

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!