struct registro{ /*Estrutura para guardar os dados do usuário*/
char usuario[50]; }atual[1000], *ptr;
main() {
int v = 0; verific = 0; //posicao e variavel para comp. de string
volta_usuario:
printf("\n\t\t\tUsuário: ");
gets(atual[v].usuario);
verific = verifica_usuario(&v);
if(verific == 0) {
printf("\t\t\tUsuário já existente");
goto volta_usuario;
} v++; goto volta_usuario;} int verifica_usuario(int *ptr){
int i;
int cmp1;
int cmp2;
for(i = -1; i < *ptr; i++) {
cmp1 = tolower(atual[*ptr].usuario);
cmp2 = tolower(atual[i + 1].usuario);
if(strcmp(cmp1,cmp2) == 0){
return 0;
}
}
return 1;}
The code above should ask the user for a name, when calling the function verifica_usuario(&v);
the program should convert the last string
read to lowercase and, lasts a loop, convert the other strings (also to lowercase), then compare and see if there are any matching strings. My goal is: if the person type "name" and then type "NAME" or "Name" (etc) the program must recognize that this user already exists, that is, does not differentiate between upper and lower case. I have tried several ways to fix the bug in this highlighted but unsuccessful function. I would like help solving this problem.