/*
*cmd.exe
*test.exe "c:/log.log" "c:/log2.log"
*/
#include <stdio.h>
int main(int argc, char *argv[])
{
FILE *fp;
FILE *fp2;
char ch;
printf("%s\n", argv[1]);
if((fp=fopen(argv[1], "rt")) == NULL)
{
printf("first Cannot open file strike any key exit!");
getch();
exit(1);
}
if((fp2=fopen(argv[2], "wt")) == NULL)
{
printf("second Cannot open file strike any key exit!");
getch();
exit(1);
}
ch = fgetc(fp);
while(ch!=EOF)
{
//putchar(ch);/*回显到屏幕*/
fputc(ch, fp2);/*文件写入*/
ch=fgetc(fp);
}
getchar();
fclose(fp);
}
C语言文件操作 简单的文件读写加外部调用
最新推荐文章于 2022-12-27 14:59:39 发布