0
I have the following struct:
typedef struct
{
    int id;
    char nome[50];
    int tipoUser;
    float vencimentos;
    int id_clinica;
} Utilizador;
I enter in the same values from the following functions :
void criarUser(Utilizador *utilizador, int n)
{
    printf("NOME: ");
    fgets(utilizador->nome, 50, stdin);
    utilizador->nome[strcspn(utilizador->nome, "\n")] = 0;
    printf("Vencimentos: ");
    scanf("%f", &utilizador->vencimentos);
    printf("tipo de user(1-Medico,2-Enfermeiro,3-Funcionario) ");
    scanf("%d", &utilizador->tipoUser);
    utilizador->id = n + 1;
    printf("id da clinica a que está associada ");
    scanf("%d", &utilizador->id_clinica);
}
boolean inserirUser(Utilizador *utilizadores, int *n, Utilizador utilizador)
{
    if (*n > TAMUtilizador)
    {
        return false;
    }
    utilizadores[*n] = utilizador;
    (*n)++;
    return true;
}
wanted now to edit the values inside the struct and would like to know why it is not working calls as functions:
 id_edicao=editarUser(utilizadores,&nUsers);
        criarComIdUser(utilizadores, id_edicao);
functions:
int editarUser(Utilizador *utilizadores, int *n)
{
    listarUsers(utilizadores, *n);
    int idAlterar;
    printf("Qual o id que quer alterar?");
    scanf("%d", &idAlterar);
    return idAlterar;
}
void criarComIdUser(Utilizador *utilizadores, int n)
{
  
    
   
    for (int i = 0; i <= n; i++)
    {
        if (i == n)
        {
            float vencimento;
            int tipoUser;
            int id_clinica;
            printf("%d",n);
            printf("Vencimentos: ");
            scanf("%f",&vencimento);
            printf("tipo de user(1-Medico,2-Enfermeiro,3-Funcionario) ");
            scanf("%d", &tipoUser);
             
            printf("id da clinica a que está associada ");
            scanf("%d",&id_clinica);
           
            utilizadores[n].id_clinica=id_clinica;
            utilizadores[n].tipoUser=tipoUser;
            utilizadores[n].vencimentos=vencimento;
            
        }
    }
}
does not return any error, simply does not edit the values, which can be?
Note, there is a small error in the scapes of / of the printf, but I believe that not affect the compilation will only give Warning.
– Talles
was even porblema with passing the Id to position inves in array , thank you very much
– Tiago
Oops, how nice it worked out.
– Talles