In this program i m creating a login system
but when i compare two variables(password) i.e member char array and password_chck that i have declared in a function, it is always returning value 0. plz help me..
Line no 110-116
Code:#include <iostream> #include <conio.h> #include <string.h> using namespace std; class Account { char password[25]; public: string uname; void pswd_in(char pw[25]); void create(); }; class Login { public: char password_chck[25], password_login[25]; string uname_login; }; int main() { char choice; int i=0; Account regist[10]; Login login[10]; do { cout << "Enter your Choice:\n1 to create account\n2 to login into your account\n3 to exit\n"; cin >> choice; if ( choice == '1') { regist[i].create(); i++; } } while( choice != '3'); return 0; } void Account::pswd_in(char pw[25]) { char c ; int i=0,j=0; while(j==0) { while((c=getch())!= '\r') { if (c == 8 ) { i--; cout << "\b \b"; } else { pw[i]=c; putch('*'); i++; } } if(i > 24 || i < 3) { cout << "\nYour Password should contain minimum 3 charachters and maximum 25 charachters.\nYour typed password is " << i << " charachters long\nType your password again\n"; i=0; } else j=1; } pw[i]='\0'; i--; password[i+1]='\0'; while (i >= 0) { password[i]=pw[i]; i--; } cout << endl; } void Account::create() { char password_chck[25]; cout << "\n**Create Your Account**\nEnter your username\n"; cin.ignore(1000,'\n'); getline(cin,uname); do { cout << "Enter your Password\n"; pswd_in(password); cout << password; cout << "\nPlease type it again for confirmation\n"; pswd_in(password_chck); cout << password_chck; cout << endl << strcmp(password_chck,password); if((strcmp(password_chck,password)) != 0) { cout << "Password does not match\n"; } } while(strcmp(password_chck,password)); }



4Likes
LinkBack URL
About LinkBacks


