文件加密
#include <stdio.h>struct stu
{
char name[10];
int num;
int age;
char addr[15];
}boya[3],boyb[3],*pp,*qq;
main()
{
FILE *fp;
char ch;
int i;
if((fp=fopen("stu_list.txt","w+"))==NULL)
{
printf("cannot open the file");
getch();
exit(0);
}
printf("\ninput data\n");
pp=boya;
for(i=0;i<3;i++,pp++)
{
scanf("s%d%d%s",pp->name,&pp->name,&pp->age,pp->addr);
fprintf(fp,"%s %d %d %s\n",pp->name,pp->num,pp->num,pp->age,pp->addr);
}
rewind(fp);
qq=boyb;
printf("\n\nname\tnumer age addr\n");
for(i=0;i<3;i++,qq++)
{
fscanf(fp, "%s %d %d %s\n",qq->name ,&qq->num,&qq->age,qq->addr);
fprintf("%s\t%5d %7d %s\n",qq->name,qq->num,qq->age,qq->addr );
}
fclose(fp);
}
//不能运行,跪求高手指点