void login(){ clrscr(); char un[25], ps[25], atype[25]; int i,c; gotoxy(20,15); cout<<"Username: "; cin>>un; gotoxy(20,16); cout<<"Password: "; for ( i = 0; i < 24 && (c = getch()) != '\r'; ++i ) { ps[i] = c; putch('*'); } gotoxy(20,17); cout<<"Usertype: "; cin>>atype; if(!strcmp(un,"technician") && !strcmp(ps,"123") && !strcmp(atype,"technician")){ technicianMenu(); } else if(!strcmp(un,"sales") && !strcmp(ps,"123") && !strcmp(atype,"sales")){ salesMenu(); } else if(!strcmp(un,"jacob") && !strcmp(ps,"123") && !strcmp(atype,"owner")){ jacobMenu(); } else{ cout<<"Invalid User name and password "; } } |
'\0'
to ps
after you finished reading the passwordYour code
[/code]coder777 (1814) Aug 8, 2012 at 2:20pm You need to add a '\0' to ps after you finished reading the password Please use code tags (the tags you used are wrong): Your code See: http://www.cplusplus.com/articles/z13hAqkS/ |
|
|
for ( i = 0; i < 24 && (c = getch()) != '\r'; ++i ) { ps[i] = c; putch('*'); } //password readed (or too long, try to fix that) ps[i] = '\0'; //terminating character. |