Reputation: 15
i've a header declared like this
#include <stdlib.h>
struct Nodo {
struct Nodo *pAnterior;
struct Nodo *pProximo;
CACHORRO cachorro;
};
typedef struct Nodo *Lista;
typedef struct Nodo *DoenteMachucado;
typedef struct Nodo *portePequeno;
typedef struct Nodo *porteMedio;
typedef struct Nodo *porteGrande;
But when i try to use the function
void inserir(Lista *lista, CACHORRO elem)
{
Lista Nodo;
Nodo = (Lista)malloc(sizeof(struct Nodo));
if(Nodo == NULL)
printf("Sem memoria\n");
Nodo->cachorro = elem;
Nodo->pAnterior = NULL;
Nodo->pProximo = (*lista);
if((*lista) != NULL)
(*lista)->pAnterior = Nodo;
(*lista) = Nodo;
}
like this
inserir(DoenteMachucado, elem);
it doesnt work, i am declaring a elem CACHORRO
Upvotes: 1
Views: 42
Reputation: 7542
void inserir(Lista *lista, CACHORRO elem)
The above statement reduces to
void inserir(struct Nodo **lista, CACHORRO elem)//1
and you call the above function as
DoenteMachucado something;
inserir(something, elem); //remember DoenteMachucado is a type not a variable ,something is a variable.so i have changed this.
where the first argument is of type struct Nodo*
inserir(struct Nodo* something, elem);//2
the parameters don't match at 1 and 2. you might want to call the function as
DoenteMachucado something;
inserir(&something, elem);
Upvotes: 1