Using files: Wacked Question
Code:
#include <abbrev.h>
main()
{
char user[2], vuser[2], pass, vpass;
ifstream fin("C:\\users.abc");
fin >> user;
fin >> pass;
fin.close();
cout<<"Please enter your name:\n";
cin>>vuser;
cout<<"\nPlease enter yourt password:\n";
cin>>vpass;
if(pass == vpass)
{
if(user == vuser)
{
cout<<"Welcome";
}
else
{
cout<<"Wrong name";
}
}
else if(user == vuser && pass != vpass)
{
cout<<"Wrong Password";
}
else if(user != vuser && pass != vpass)
{
cout<<"Wrong name and password";
}
else
{
cout<<"Something went Wrong!!";
}
cin>>vpass;
return 0;
}
this code runs with no compile errors, but it always turns out as "Something went Wrong!!". I checked and "user" has the first 4 letters of the username and cuts off the fifth letter and replaces it with the password. WTF???