hello guys.. i hope you can help me for this codes..
im trying to make a program that will accept username and password in c++.
im using turbo c++ ide 3.0
"not dev c++".
here is my code..
but the problem is.., i want to use * to appear as password character in my codes.
but everytime i press enter key, the program consider it as *.
so i need to press enter key again to proceed to the program yet it will generate error because
the first time i pressed enter was consider as part of the password.
#include<iostream.h>
#include<conio.h>
main()
clrscr();
char a[30], b[30], c=' ' ;
cout<<"Enter Username: ";
cin.getline(a,29);
cout<<"Enter Password: ";
while(c!=13)
{
c=getch();
cout<<"*";
}
cin.getline(b,30);
if (a[0]=='l' && a[1]=='u' && a[2]=='f' && a[3]=='f' && a[4]=='y' && b[0]=='g' && b[1]=='a' && b[2]=='r' && b[3]=='p')
{
cout<<"password correct:";
goto tama;
}
else
{
cout<<"Password Failed!!";
getch();
return 0;
}
tama:
clrscr();
cout<<"username and password correct"<<endl;
getch();
return 0;
}
thank you guys.. i hope you will consider to help