0
The next function should turn variables into lowercase and then compare them. I’ve tried converting before, but also bugged. Arithmetic use of pointers together with variables of a struct
. Pointer points to the struct
.
How to fix the error present in the following code snippet:
struct registro{
char conta[50], senha[50], usuario[50];
}atual[1000], *ptr;
int verifica_usuario(int *ptr){
int i;
for(i = 0; i < *ptr; i++) {
if(strcmp(tolower(atual[*ptr].usuario), tolower(atual[i].usuario)) == 0) {
return 0;
}
}
return 1;
}
"Arithmetic pointer use" no, you do not use pointer arithmetic. You use a simple positional vector access
atual
. And also passint *ptr
as argument seems quite unnecessary for the use being made of it– Jefferson Quesado
Yes, yes. My goal follows this conviction, I want the program to classify "NAME" == "name", hence the tolower. the program receives an entry in which it asks for a user name, but this name cannot already be registered, even if there is divergence between upper and lower case.
– eddunic
tolower
receives a char and returns a char, so it makes no sense to call for a charchar[]
orchar*
.atual.usuario
is of what type ?– Isac
It’s kind of char, too.
– eddunic
Put the definition of
struct
in the question, so that it is evident to anyone who wants to answer– Isac
What Isac meant was, how’s the code of
struct
between the word recervadastruct
, your key opener{
and their respective key closes}
with all field definitions and their respective names– Jefferson Quesado
What are you calling your role in
main
?– Isac
verific = verifica_account(&v);
– eddunic