#include<stdio.h>
#include<windows.h>
#include<string.h>
int main(void){
char name[32];
char password[32];
FILE*data;
char name_tmp[32];
char password_tmp[32];
char line[64];
char * ret;
data=fopen("C:\\text.txt","r");
if(!data){
printf("文本打开失败!");
return 1;
}
while(1){
printf("请输入用户名:");
scanf("%s",&name);
printf("请输入密码:");
scanf("%s",&password);
while(1){
ret=fgets(line,sizeof(line),data);
if(!strcmp(name,name_tmp)&&!strcmp(password,password_tmp)){
break;
}
sscanf(line,"%s%s",name_tmp,password_tmp);
if(!strcmp(name,name_tmp)&&!strcmp(password,password_tmp)){
break;
}
}
if(ret){
break;
}else{
printf("\n");
system("pause");
system("cls");
fseek(data,0,SEEK_SET);
}
}
system("cls");
printf("---交换机后台管理---\n");
return 0;
}
原文地址:https://www.cnblogs.com/fzhiyaoy/p/10415768.html