Conversion error in c::b

Asked

Viewed 29 times

0

I have a queue set like this:

typedef struct nodo
{
   int inf;
   struct nodo *next;
}NODO;

typedef struct
{
   struct nodo *INICIO;
   struct nodo *FIM;
}DESCRITOR;
typedef DESCRITOR *FILA_ENC;

And a function that queries and removes the first element of the queue:

int cons_ret (FILA_ENC f)
{
    if (eh_vazia(f))
    {
        printf ("retirada em fila vazia");
        exit(5);
    }
    int val=f->INICIO->inf;
    FILA_ENC aux=f->INICIO; /*erro aqui*/
    f->INICIO=f->INICIO->next;
    if (!f->INICIO)
    f->FIM=NULL;
    free(aux);
    return (val);
}

Only it’s giving an error that says "cannot Convert 'NODO* {aka nodo*}' to 'FILA_ENC {aka DESCRIPTOR*}' in initialization", and I don’t know why.

  • 1

    Would not be FILA_ENC aux = f;?

1 answer

1


Its variable aux is the type DESCRITOR *, already the attribute f->INICIO is the type struct nodo*. Are pointers to different types, you can not assign from one to the other.

Browser other questions tagged

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