| RemoteC2 |
Aug 9th, 2006 11:43 PM |
simple password checker
i created a program that prompts the user to give a psswrd, then the program stores the password. the program then checks the password. but when it gets to the part where it checks the password, no matter what i do, it never sees that the two strings are the same...i was wondering if i someone could point me in the right direction?
anyways, here is the code:
:
//store/check password
#include <iostream>
#include <cstdlib>
using namespace std;
class pswrd {
public:
char ps[80], usr[80];
int len;
void set_ps (char *p) {strcpy(ps, p);}
void check_ps () {
printf("\nPassword: ");
cin>>usr;
if(usr!=ps) cout<<endl<<"Access Denied";
else if(usr==ps) cout<<endl<<"Access Granted";
}
};
int main ()
{
pswrd ob1;
char p[80];
printf("Set Password: ");
cin>>p;
ob1.set_ps(p);
ob1.check_ps();
system("PAUSE");
}
|