您的位置:首页 > 运维架构 > Linux

Linux 上标准c复制文件

2017-12-19 20:30 225 查看
#include "stdafx.h"
#include<stdio.h>
#include<stdlib.h>
int _tmain(int argc, _TCHAR* argv[])
{
char *path = "C:\\Users\\Administrator\\Desktop\\original.PNG";
char *newpath = "C:\\Users\\Administrator\\Desktop\\copy.PNG";
//标准c复制文件
FILE *file = fopen(path, "rb");
FILE *copy = fopen(newpath,"wb");
if (file == NULL){
printf("%s\n","文件打开失败!。。。");
return -1;
}

if (copy==NULL)
{
printf("%s\n", "文件打开失败");
return -1;
}

int buffer[50] = {0};
int temp = 0;
while ((temp=fread(buffer, sizeof(int), 50, file))>0)
{
printf("读取个数:%d\n",temp);
fwrite(buffer, sizeof(int), temp, copy);
}
printf("读取完成");

int clsoe1=fclose(file);
int close2=fclose(copy);
printf("关闭结果:%d和%d\n", clsoe1, close2);
return 0;
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c语言 linux 文件复制