I wanted a program that checks the user and password, if it was correct to display a message, if it repeated the check and if the attempts were equal to 3, it showed the limit message of attempts reached.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char user[20];
int senha, contador = 0;
printf("Entre com o usuario: ");
gets(user);
printf("Entre com a senha: ");
scanf("%d", &senha);
while((strcmp(user, "leonardo") == 0) && senha == 123) {
if(1) {
printf("\nAcesso concedido.\n");
break;
} else {
contador = contador + 1;
gets(user);
scanf("%d", &senha);
} if(contador == 3) {
printf("Limite de tentativas alcancadas.\n");
}
}
printf("Fim.\n");
return 0;
}
I'm having difficulty with loops .