我只想创建一个小型加密程序,我想从文件中读取字符并将 i 的当前值添加到字符中并将其存储在一个新文件中。
示例:abcd应存储为aceg
这是代码片段:
main()
{
int i=0,c;
char filename[30],o_filename[30];
FILE *file,*outfile;
printf("\nEnter filename:");
scanf("%s",&filename);
printf("\nEnter output filename : ");
scanf("%s",&o_filename);
if( ( (file = fopen(filename,"a"))==NULL) || ((outfile = fopen(o_filename,"a+"))==NULL))
printf("\nERROR - Cannot proceed");
else
{
c = 0;
while(c!=-1)
{
c = getc(file);
putc((c+i),outfile);
i++;
}
printf("\nEncryption Successful!\n");
}
getch();
}
上述程序有什么错误?