Error of Conflicting types for 'login'

Asked

Viewed 36 times

1

I’m making a login screen, but my code is giving error:

Conflicting types for 'login'.

I’m a beginner in the area and I’m not able to understand what to do to fix this, someone could help me?

typedef struct{
    char login[30];
    char senha[30];
} usuario; usuario u[0];

void tela_login()
{

    FILE *login;
    login = fopen("login.txt", "a"); //"a" para adicionar no txt
    if (login == NULL) {
        printf("\nO arquivo não foi aberto!");
        exit(0);
    }
    system("cls");
    
    char login[30];
    char senha[30];
    int contador;
    
    for(contador = 1;contador<=3;contador++){
    system("cls");
    
    strcpy(u[0].login, "admin");
    strcpy(u[0].senha, "202020");

        printf("Digite o login do usuario ADMIN:  ");
        fgets (u[0].login,30, stdin);
    
        printf("Digite a senha do usuario ADMIN:  ");
        fgets (u[0].senha,30, stdin);

    while(fgets(u[0].login && u[0].senha,30, stdin) != NULL) {
    if((strcmp(login,u[0].login)==0) && (strcmp(senha,u[0].senha)==0)){
        printf("Seja bem vindo");
    }else{
        printf("Login e/ou senha invalidos, tente novamente!");
    }
    }
        printf("Login e/ou senha bloqueado temporariamente");
    }
    fclose(login);

}
  • After all login is a FILE or char array? FILE *login; and char login[30];

  • FILE *login is for the creation of the file and then manipulation and char login[30] is to inform the size of the vector used for the login, but you think the two can not have the same name because they are conflicting? I tried to modify it once but had trouble compiling the rest of the code, so I’m getting suggestions because the more I move the worse it gets and being a beginner I don’t know exactly what to do

  • You cannot give the same name to different things. This is basic in programming.

  • Thank you for the clarification!

  • @anonimo Create an answer with what you have commented to end this question with a valid answer.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.