#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define LINE 5 //每次处理的行数
void main()
{
void Inputsource(char *sourcefile);
void Outputdoc(char *docfile);
void encode(char *sourcefile,char *codefile,char *key);
void decode(char *codefile,char *docfile,char *key);
char *sourcefile="source_doc.dat";
char *codefile="code.dat";
char *docfile="doc.dat";
char key[26];
printf("Input the key word : /n");//输入密钥
scanf("%s",key);
getchar();
Inputsource(sourcefile);//输入明文
encode(sourcefile,codefile,key);//加密处理
decode(codefile,docfile,key);//解密处理
Outputdoc(sourcefile);//输出文件信息
Outputdoc(codefile);
Outputdoc(docfile);
}
void Inputsource(char *sourcefile)
{
FILE *fpw_source;
char ch;
if((fpw_source=fopen(sourcefile,"w"))==NULL)
{
printf("Open source file Failure!!/n");
exit(0);
}
printf("/nIn put your source doc ,and '!' for end :/n");
while((ch=getchar())!='!')
{
fputc(ch,fpw_source);
}
fclose(fpw_source);
}
void Outputdoc(char *docfile)
{
FILE *fpr_doc;
char ch;
if((fpr_doc=fopen(docfile,"r"))==NULL)
{
printf("Open docfile file Failure!!/n");
exit(0);
}
printf("/nThe text of %s is :/n",docfile);
while((ch=fgetc(fpr_do