I means Password is ev1l.if keyboard input is a,input will stop and go work for next line and then input again.How to break it first char is wrong in password program?
My Program code is here.,
Code:
#include <stdio.h>
#include <conio.h>
#include <string.h>
int main ()
{
char pass[]="ev1l";
char password[10];
int loginAttempt = 0;
while (loginAttempt < 5)
{
printf("Enter Password: ");
scanf("%s",password);
if(strcmp(password,pass)==0)
{
printf("Correct! Congratulations!\n");
break;
}
else
{
printf("Password is wrong!.\n");
loginAttempt++;
}
}
if (loginAttempt == 5)
{
printf("Only five attempts tried. Program will exit.");
return 0;
}
getch();
return 0;
}
Please help me ,I'm newbie in C programming.