Dear sir,

I trying to create a password menu. How can I limit the maximum of password characters to 10 and if the users enter invalid characters how can I erase the prevous or wrong password and than back to the stating point (gotoxy(41,11)) try again.


#define KEY "PASS"

void main(void)
{
char password[10];
int count;
int tries = 1;
char shutdown[] = "PROGRAM ABORTED!";
int index;

clrscr();

textcolor(LIGHTBLUE);

gotoxy(25,11); cprintf("PASSWORD ");

do
{
gotoxy(41,11);
count = 0;

while (password[count-1] != 8)
{
password[count] = getch();
printf("*");
count++;
}
password[count-1] = '\0';


if (strcmp(password, KEY) == 0)
{

main_menu_selection();
}

else

{
gotoxy(32,16);
textcolor(RED + BLINK);
cprintf("WRONG PASSWORD");
tries++;

if (tries == 4)
{
index = 0;
textcolor(RED);
clrscr();
gotoxy(24,10);
while (shutdown[index] != '\0')
{
printf("%c", shutdown1[index]);
index++;
}
}

} while ((strcmp(password, KEY) != 0) && (tries != 4));


getch();
}


Thanks

Xiang