#include<stdio.h>
#include<stdlib.h>
#include<Windows.h>
int main(int argc,char* argv[])
{
FILE* pfRead = NULL;
FILE* pfWrite = NULL;
int ch = 0;
if(argc != 3)
{
perror("参数出错\n");
exit(EXIT_FAILURE);
}
pfRead = fopen(argv[1],"r");
if(pfRead == NULL)
{
perror("open file for read\n");
exit(EXIT_FAILURE);
}
pfWrite = fopen(argv[2],"w");
if(pfWrite == NULL)
{
fclose(pfRead);
perror("open file for write\n");
exit(EXIT_FAILURE);
}
while((ch = fgetc(pfRead)) != EOF)
{
fputc(ch,pfWrite);
}
fclose(pfRead);
fclose(pfWrite);
system("pause");
return 0;
}
【C语言】没事可以试试这个小程序,使用文件操作,模拟实现一个简单的文件拷贝工具!
最新推荐文章于 2019-05-14 01:58:00 发布