#include <stdio.h> #include <stdlib.h> void main(int argc,char*argv[]) { FILE *fp1,*fp2; char c,ch; long j; char *in_file,*out_file; if(argc!=3) { printf("\ninput the in_file:"); gets(in_file); printf("\ninput the out_file"); gets(out_file); } else { strcpy(in_file,argv[1]); strcpy(out_file,argv[2]); }
if(!(fp1=fopen(in_file,"rb"))) {printf("\ncannot open the in_file"); exit(1); } fp2=fopen(out_file,"wb"); if(!fp2) { printf("\ncannot open the out_file"); exit(1); } printf("\ninput the passwd:"); scanf("%i",&j); srand(j); /*初始化随机函数生成器*/ ch=fgetc(fp1); while(!feof(fp1)) { c=rand(); ch=ch^c; fputc(ch,fp2); ch=fgetc(fp1); } fclose(fp1); fclose(fp2); printf("\nlock file successfully!"); exit(0); } 编译运行时,说“cannot open the out_file” 可如果要加入两个没有什么作用的输出语句就可以拉 比如:
[此贴子已经被作者于2005-3-31 13:31:35编辑过]