linux实现将一个加密过的文件exam1.txt中的内容转换为正常的文字后写入exam2.txt的程序,解密方法是将exam1.txt中的所有字符均加上9,其中空格(ASCII码32)、逗号(ASCII码44)和句号(ASCII码46)不变。
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
int main(int argc,char *argv[])
{
FILE *fp1;
int ch;
if(argc!=2)
{
printf("command error!\n");
return -1;
}
if((fp1=fopen(argv[1],"r"))==NULL)
{
printf("file %s cannot open",argv[1]);
return -1;
}
while((ch=fgetc(fp1))!=EOF)
{
fputc(ch,stdout);
}
fclose(fp1);
return 0;
}
估计没看懂,都一样的。