📅  最后修改于: 2022-03-11 14:44:54.194000             🧑  作者: Mango
#include
#include
#include
#include
#include
void register_user();
void login_user();
void main_menu();
int IsLoggedIn()
{
char username[20],password[20],un[20],pw[20];
cout<<"Enter Username: ";gets(username);
cout<<"Enter Password: ";gets(password);
ifstream read(username + ".txt");
getline(un,read);
getline(pw,read);
if(un==username && pw==password)
{
return 1;
}
else
{
return 0;
}
}
void main()
{
main_menu();
}
void main_menu()
{
int choice;
cout<<"1. Register\n2. Login\nYour Choice: "; cin>>choice;
switch(choice)
{
case 1: register_user(); break;
case 2: login_user(); break;
default: break;
}
}
void register_user()
{
char username[20], password1[20],password2[20];
cout<<"Enter Username: ";gets(username);
rev1:cout<<"Enter Password: ";gets(password1);
cout<<"Enter Password again: ";gets(password2);
while (password1!=password2)
{
goto rev1;
}
ofstream file;
file.open(username + ".txt");
file<