如果你已经指定好了文件名,那你还要argv参数来干吗~~所以既然你有argv函数,那我就用他们来确定文件名。
当然,如果你不喜欢也可以改回来的,只要你说一声
淘宝杜琨
好的 不过前提仍然是1.txt要和pass.exe在同一个文件夹中呀,这点一定要注意咯 #include "stdio.h" #include "stdlib.h"
int main(int argc,char *argv[]) { FILE *fp1,*fp2,*fp3; char ch;
/* 看看参数是否对 */
/* 读原文件 */ if((fp1=fopen("1.txt","r"))==NULL) { printf("cant open %s \n","1.txt"); exit(0); }
/* 加密的程序 */ if((fp2=fopen("2.txt","w"))==NULL) { printf("cant open %s \n","2.txt"); exit(0); }
for(; (ch=fgetc(fp1))!=EOF; ) { putch(ch);/*打印1.txt的内容*/ ch=ch +4; fputc(ch,fp2); }
printf("\n"); /*换行*/
fclose(fp1); fclose(fp2);
/* 在打开文?*/
fp2=fopen("2.txt","r"); if((fp3=fopen("3.txt","w"))==NULL) { printf("cant open %s \n","3.txt"); exit(0); }
for(; (ch=fgetc(fp2))!=EOF; ) { putch(ch);/*打印2.txt的内容*/ ch=ch -4; fputc(ch,fp3); }
printf("\n"); /*换行*/
fclose(fp2); fclose(fp3);
if((fp3=fopen("3.txt","r"))==NULL) { printf("can't open 3.txt"); }
for(; (ch=fgetc(fp3))!=EOF; ) { putch(ch);/*打印3.txt的内容*/ } }
#include "stdio.h" #include "stdlib.h"
int main(int argc,char *argv[]) { FILE *fp1,*fp2,*fp3; char ch; /* 看看参数是否对 */ /* 读原文件 */ if((fp1=fopen("1.txt","r"))==NULL) { printf("cant open %s \n","1.txt"); exit(0); }
/* 加密的程序 */ if((fp2=fopen("2.txt","w"))==NULL) { printf("cant open %s \n","2.txt"); exit(0); }
for(; (ch=fgetc(fp1))!=EOF; ) { putch(ch); /*输出第一个文件的内容*/ ch=ch +4; fputc(ch,fp2); }
printf("\n");/*换行*/ fclose(fp1); fclose(fp2);
/* 在打开文?*/ fp2=fopen("2.txt","r"); if((fp3=fopen("3.txt","w"))==NULL) { printf("cant open %s \n","3.txt"); exit(0); }
for(; (ch=fgetc(fp2))!=EOF; ) { putch(ch);/*输出第二个文件的内容*/ ch=ch -4; fputc(ch,fp3);
}
printf("\n");/*换行*/
fclose(fp2);
fclose(fp3); if((fp3=fopen("3.txt","r"))==NULL) { printf("cant open %s \n","3.txt"); }
for(; (ch=fgetc(fp3))!=EOF; ) { putch(ch); /*输出第三个文件的内容*/ } }
[此贴子已经被作者于2005-1-12 14:08:35编辑过]