#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;
}
Linux 上标准c复制文件
最新推荐文章于 2024-04-29 20:27:38 发布