user login in c++

i am making a login form but it is not comparing the user input values to the values in the file correctly here is my code

int login()
{
int choice ;
string username , matchuser ,password , matchpass;
cout<<"Admin Login"<<endl;
cout<<"Custmer Login"<<endl;
cout<<"enter 1 for admin login and 2 for custmer login"<<endl;
cin>>choice;
system("cls");

cout<<"Enter your username"<<endl;
cin>>username;
cout<<"enter your password"<<endl;
cin>>password;
cout<<"please wait"<<endl;

if(choice==1){ifstream admin("D:\\project\admin.txt" , ios::app); admin<<matchuser<<matchpass;
else{ifstream admin("D:\\project\custmer.txt");admin>>matchuser>>matchpass;}

if(matchuser==username && matchpass==password){cout<<"access granted"<<endl;}
else{cout<<"wrong information"<<endl;}}

};
admin<<matchuser<<matchpass;
admin is an ifstream. Why do you try to write to it?
Topic archived. No new replies allowed.