hey,
The following code is suppossed to allow someone to type in a username and password and it would log in. I ran into a big problem though that I can't figure out what the problem is. It's probably something simple but I can't figure it out.
Everything works right up until the part where I put comments (//HERE). It doesn't seem to work, it always skips the if statement even if the passwords do not mach...
Thanks.Code:void login() { //Test Variables char testaccname[50]; char testaccpass[50]; char buffer[50]; //Display Title cout<<endl <<endl <<"Login\n"; cout<<"---------------------------\n"; //Get Account Name accname: cout<<"Account Name: "; cin.getline ( testaccname, 50 ); //Check To See If Account Name Exists ifstream test_file ( testaccname ); if (! test_file.is_open() ) { cout<<"Invalid Account Name!\n" <<endl; goto accname; } //Get Password From File test_file.getline( buffer, 50 ); test_file.getline( buffer, 50 ); accpass: cout<<"Account Password: "; cin.getline( testaccpass, 50 ); //HERE if (! buffer == testaccpass ) { cout<<"Invalid Password!\n" <<endl; goto accpass; } //HERE cout<<"Login Success!\n"; getch(); return; }
Anthony