Error in list of structures in C

0

I'm working on a structure list code, where I have a struct called cad that contains the registration, name, and salary fields. And a list containing a field of type struct cad that stores the fields of the struct cad in list form. So the code looks like this:

#define MAX 5

struct cad
{
    int mat;
    char nome[30];
    float sal;
};

struct lista
{
    int fim;
    struct cad memo[MAX];
};

typedef struct lista lista;
typedef struct cad cad;
int main()
{   lista l;
    cad x;
    int opc, pos;
    l.fim = -1;

do
{
    opc = menu();
    switch(opc)
    {
    case 1: //enfileirar
        if(l.fim==MAX-1)
            {
                printf("Lista Cheia ");
            } 
            else
            {
                printf("Matricula = ");
                scanf("%d", &x.mat);
                printf("Nome = ");
                fflush(stdin);
                gets(x.nome);
                printf("Salario = ");
                scanf("%f", &x.sal);
                inserir(&l, x);
            }
        break;

        case 2: //remover
            if(l.fim==-1)
            {
                printf("Lista vazia ");
            }
            else
            {
                x=remover(&l);
                printf("\n matricula = %d", x.mat);
                printf("\n nome = %s", x.nome);
                printf("\n salario = %f", x.sal);
            }
         break;

But when I create a function that can remove the information in one of the positions of struct cad memo, I get the error of "incompatible types when assigning to type 'cad' from type 'int' |"

The remove function looks like this:

struct cad remover(lista *l)
{
    int i;
    struct cad aux;

    aux = l->memo[0];
    for(i=0;i<l->fim; i++)
    {
        l->memo[i] = l->memo[i+1];
    }
    l->fim--;
    return aux;
}

Could someone clarify why I made this mistake?

    
asked by anonymous 09.06.2018 / 19:22

0 answers