Simple password checking !
hello I want to check if the 5-entered characters by a users match a stored string
but it is not workin.......
here is my code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
# include <iostream>
# include <conio.h>
using namespace std ;
int main ()
{
char pass [6] ;
char correctpass [6] = {"ABCDE"};
int counter = 0 ;
cout << "Enter a 5 character password: " ;
while (counter < 3)
{
for (int i=0 ; i<5 ; i++)
{
pass [i]= getch() ;
cout <<"*" ;
}
cout << endl;
int returnValue = strcmp (pass,correctpass);
if (returnValue == 0)
{
cout << "Correc Password !" << endl;
break ;
}
else
{
cout << "Invalid Password !" << endl;
counter ++ ;
}
}
system ("pasue");
}
|
do not forget to place '\0' at the end of pass array: pass[5] = '\0'
ok thx I've figured out thx
Topic archived. No new replies allowed.