您的位置:首页 > 编程语言 > C语言/C++

学习C/C++语言:文件的操作

2014-05-14 17:46 232 查看
#include<stdio.h>
#include<stdlib.h>
void main(int argc,char *argv[])
{
FILE *in,*out;
if(argc!=3)
{
printf("you forgot to enter a file name\n");
exit(0);
}
if((in=fopen(argv[1],"r"))==NULL)
{
printf("cannot open inflie\n");
exit(0);
}
if((out=fopen(argv[2],"w"))==NULL)
{
printf("cannot open inflie\n");
exit(0);
}
while(!feof(in))
fputc(fgetc(in),out);
fclose(in);
fclose(out);
}


doc:

 c:\>  copy.exe in.txt out.txt
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: