0
Good evening... I am making an automatic login system and the validation worked agr the only problem is that it is not possible to delete the previous character if the user misses the letter, I would like to know how would the user event press the Backspace key to delete the wrong character Obs - code below
#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
#include <string.h>
char vetor[50];
char user[]= "usuario";
char senha[]= "senha";
int i = 0, c, t=0, j=0, cont=0;
int main(){
void Validacao(char vetor[50],int valida, char desejado[50]);
void ValidacaoSenha(char vetor[50],int valida, char desejado[50]);
//para entrada e reconhecimento da senha versão 1.0
printf("\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t\tLogin >> ");
Validacao(vetor,strlen(user),user);
}
void Validacao(char vetor[50],int valida, char desejado[50]){
int i = 0, c, t=0, j=0, cont=0;
do{
c=getch();
fflush(stdin);
vetor[i] = c;
printf("%c", vetor[i]);
i++;
if(vetor[j] == desejado[j]){
cont++;
}
j++;
if(cont==valida){
t=1;
}
} while (t!=1);
}
Even better to say
scanf(" %49s", vetor);
that guarantor that thescanf()
will not read more than 49 characters at once (leaving the 50th free to win the'\0'
terminator).– Wtrmute