-
help on code
#include <stdio.h>
#include <conio.h>
#include <string.h>
void Password (void);
main()
{
Password();
}
void Password(void)
{
char Passwordin[20];
gotoxy(30,4);printf("Password Identification");
gotoxy(17,8);printf("\t\tPlease enter password : ");
scanf("%s",Passwordin);
//check if user entered correct password dcampbell using strcmp
if(strcmp(Passwordin,"dodon")==0)
{
gotoxy(17,10);printf("Correct Password ");
getch();
}
else
{
// if password incorrect Password function recalled until correct Password entered
gotoxy(17,10);printf("\t\tincorrect password\n");
getch();
Password();
}
}
The above code when u enter an incorrect password, the program halts and wont give me the option of re-entering a password - any ideas? also how would you be able to have ***** appear on screen as the password being entered instead of the text appearing on screen? cheers
-
To make code that would ask to reenter password just put your codw in the infinite loop (while(true) { ..... }; for example).
Now if you whant ******** do the following:
char ch[10];
for(int i=0; i<10; i++)
{
char[i] = getch();
cout << "*";
{
that should do it.
:)