So what i see is it is a bad implementation, nothing will be writed in that list?
I just try tu use a print function and nothing is printed
Code:
#include <stdio.h>
#include <stdlib.h>
typedef struct churr{
char mat[100];
char pedido[100];
float preco;
}INFO;
typedef struct elem{
INFO nodo;
struct elem *Seguinte;
struct elem *Anterior;
}ELEM;
int recebeCliente(INFO info, ELEM **initlista, ELEM **fimlista)
{
ELEM *novo;
novo=(ELEM*)malloc(sizeof(ELEM));
novo->nodo=info;
novo->Seguinte=NULL;
novo->Anterior=NULL;
if(novo==NULL)
{
printf("Erro na lista...");
return -1;
}
if(*initlista==NULL)
{
novo=*initlista;
novo=*fimlista;
}
else
{
novo->Anterior=*fimlista;
(*fimlista)->Seguinte=novo;
*fimlista=novo;
}
return 0;
}
int listar(ELEM *initlista)
{
ELEM *aux;
aux=initlista;
while(aux!=NULL)
{
printf("%s %s %.2f", aux->nodo.mat, aux->nodo.pedido, aux->nodo.preco);
aux=aux->Seguinte;
}
return 0;
}
int main()
{
ELEM *initlista=NULL, *fimlista=NULL;
INFO info;
printf("Matricula: \n");
gets(info.mat);
printf("Descricao: \n");
gets(info.pedido);
printf("Preco: \n");
scanf("%f",&info.preco);
getchar();
recebeCliente(info,&initlista,&fimlista);
listar(initlista);
return 0;
}
*No more warnings with
{
}
in insert funtion