求帮忙分析一下
这段代码在写入时写不进去#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int right(char *password)
{
int i,j,z;
char y[7]="123456";
for(i=0,j=0;i<6,j<6;i++,j++)
{
if(password[i]!=y[j])
return z=0;
}
}
void DecryptFile(FILE *sfp,FILE *dfp,char *pwd)
{
char ch;
int i=1;
while((ch=fgetc(dfp))!=EOF) //就是这一步,直接跳了
{
ch=ch+pwd[i];
i++;
fputc(ch,sfp);
}
}
void OutputFile(FILE *fp)
{
char ch;
while((ch=fgetc(fp))!=EOF)
putchar(ch);
}
int main(int argc,char *argv[])
{
char *pwd;
char ch;
FILE *sfp,*dfp;
printf("需要解密的文件为:\n");
puts(argv[1]);
printf("加密后的文件为:\n");
puts(argv[2]);
printf("密码为:\n");
puts(argv[3]);
if(right(argv[3])!=0)
{
if((dfp=fopen(argv[2],"r"))==NULL)
{
printf("无法打开文件 :%s\n",argv[2]);
exit(0);
}
printf("加密后的内容为:\n");
OutputFile(dfp);
if((sfp=fopen(argv[1],"w+"))==NULL)
{
printf("无法打开文件 :%s\n",argv[1]);
}
DecryptFile(sfp,dfp,argv[3]);
printf("\n解密之后的内容为:\n");
fseek(sfp,0L,SEEK_SET);
OutputFile(sfp);
fclose(sfp);
fclose(dfp);
}
else
printf("密码错误");
return 0;
}