Hello everybody! I am just a beginner in C, so i have some problems with the password input . This is for bank account, it asks user for password input, but it doesn't works properly for three attempts, in order to go to menu: Could you help me please, what is the problem in? the piece of code is here:
attempt = 0;
while((attempt<MaxAttempt)&&!correct)
{
attempt = attempt+1;
puts ("\nEnter your password");
fflush(stdout);
while ((che = getch()) != EOF && che != '\n' && che != '\r' && i < sizeof(pword) - 1)
{
if (che == '\b' && i > 0)
{
printf("\b \b");
fflush(stdout);
i--;
pword[i] = '\0';
}
else if (isalnum(che))
{
putchar('*');
pword[i++] = (char)che;
}
}
pword[i] = '\0';
strcpy(word,pword);
printf ("\nYou entered >%s<", word);
fseek(members, sizeof(account)*here, SEEK_SET);
fread(buffer, sizeof(account),1,members);
printf("%s %s", buffer->acc_name, buffer->pin);
if (!strcmp(word, buffer->pin))
{
printf("Access granted\n\n\n");
correct=TRUE;
break;
goto menu;
}
else
{
if(attempt<MaxAttempt) printf("\n incorrect password\n")
else {printf("Your card is confiscated\n"); exit(1);}
}
}
Thank you :)