作业:
1. 注册功能
2. 用fgetc实现一个文件有几行,文件大小
printf("*********************************\n");
120 char c4[20],c5[20];
121 int count=0,count1=0;
122 printf("请输入账户名和密码:");
123 scanf("%s%s",c4,c5);
124 //fscanf(fp,"%s%s",fileName,file_passwd);
125 while(1)
126 {
127 if(fscanf(fp,"%s%s",fileName,file_passwd)==EOF)
128 break;
129 count++;
130 printf("%s\n",fileName);
131 if(strcmp(fileName,c4)==0)
132 {
133 printf("%s %s已存在\n",c4,c5);
134 return -1;
135 }
136
137
138 }
139 //fseek(fp,-1,SEEK_END);
140 fp=fopen("usr.txt","a");
141 count1+=fprintf(fp,"%s %s",c4,c5);
142 count++;
143 printf("录入成功\n")
fp=fopen("usr.txt","r");
146 while(fgetc(fp)!=EOF)
147 count1++;
148
149 printf("文件有%d行,文件大小为%d\n",count,count1);
运行效果图片
注册文件图