This is a function of my code. Whenever, i am loging in as any user, it,s fine for the first time. But, from the second time it doesn't fetch the string value from the file to match with the password provided by the user.
int userLogin(){
int studentUser;
string studentPassword;
int x=1;
system("cls");
cout<<"\n ---------- Student Login -------";
cout<<"\n\n Enter username: ";
cin>>studentUser;
cout<<"\n Enter password:";
cin>>studentPassword;
char filename[20];
sprintf(filename,"%d%s",studentUser,".dat");
ifstream fin(filename,ios::in);
student t;
fin.read((char*)&t,sizeof(t));
if(t.PASSWORD==studentPassword){
while (x!=0){
int innerChoice = 0;
while(innerChoice != 9){
system("cls");}}}
for every time user should give the username and password to login. using the username the file will be located , then password from the file will be matched with the entered password.