#include <stdio.h>
#include <process.h>
int main(){
int n;
FILE *fp;
char ch,str[30],filename[30];
printf("please input the filename:\n");
scanf("%s",filename);
if((fp=fopen(filename,"w"))==NULL){
printf("can not open filename:\n");
exit(0);
}
printf("please input the number:\n");
getchar();
gets(str);
fputs(str,fp);
fclose(fp);
if((fp=fopen(filename,"r"))==NULL){
printf("can not open filename:\n");
exit(0);
}
ch=fgetc(fp);
while(ch!=EOF){
putchar(ch);
ch=fgetc(fp);
}
printf("\n");
n=ftell(fp);
if(n==6){
printf("密码设置成功\n");
}else{
printf("密码设置失败\n");
}
fclose(fp);
return 0;
}