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

时间:2014-05-14 21:37:56   收藏:0   阅读:321
#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

学习C/C++语言:文件的操作,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!