对文件加密小程序出了点小问题帮忙看看!
#include<stdio.h>#include<string.h>
char encrypt(char f,char c)
{return(f^c);}
void main()
{FILE *fp,*fp1;
char fn[40],*p=fn,ps[10],*s=ps;
char ch;
char *tm="E:\ruanjian";
printf("Input the path and filename:");
gets(p);
*tm=*p;
if((fp=fopen(p,"rb"))==NULL||(fp1=fopen(tm,"wb"))==NULL)
{printf("Cannot open the file,strike any key to exit!!");
getch();
exit(1);
}
printf("Input the password!!");
gets(s);
ch=fgetc(fp);
while(!feof(fp))
{s=ps;
while(*s!='\0')
ch=encrypt(ch,*s++);
fputc(ch,fp1);
ch=fgetc(fp);
}
fcolse(fp);
fclose(fp1);
remove(p);
rename(tm,p);
}
这是个对文件进行加密的小程序,但是总是显示三个错误,由于经验不足,没有弄明白!希望高人帮忙看看!
下面是三个错误:
E:\C语言\对文件的加密\hehe\对文件的加密.cpp(15) : error C2065: 'getch' : undeclared identifier
E:\C语言\对文件的加密\hehe\对文件的加密.cpp(16) : error C2065: 'exit' : undeclared identifier
E:\C语言\对文件的加密\hehe\对文件的加密.cpp(28) : error C2065: 'fcolse' : undeclared identifier