文件的加密和解密
#include"sequence.cpp"#define MAX 100
char str[MAX];
int readData()
{
FILE *fp;
int i=0;
if((fp=fopen("a.txt","r"))==NULL)
{
printf("can not open file");
exit(1);
}
fscanf(fp,"%s",str);
puts(str);
fclose(fp);
return i;
}
int main()
{
int n;
int i;
printf("请输入密码:");
scanf("%d",&n);
for(i=0;i<readData();i++)
{
str[i]=str[i]+n;
}
str[i]='\0';
StackNode s;
Init();
for(i=0;i<readData();i++)
{
Push(&s,str[i]);
}
i=0;
while(!Empty (&s))
{
str[i]=Pop(&s);
i++;
}
str[i]='\0';
printf("加密结果为:\n");
for(i=0;i<readData();i++)
{
printf("%s",&str[i]);
}
return 0;
}感觉像是进入了死循环,帮忙看一下