-2
I’m trying to make a circular list but whenever I compile this giving error. Could point me the error?
#include <stdio.h>
#include <stdlib.h>
typedef struct lista
{
int info;
struct lista *prox;
} lista;
lista* criarLista(void)
{
return NULL;
}
lista* inserirListaFim(lista* l, int i)
{
lista *novo = (lista*)malloc(sizeof(lista));
novo->info = i;
novo->prox = l;
return novo;
}
int listaVazia(lista *l)
{
if(l==NULL)
{
return 1;
}
else
{
return 0;
}
}
void imprimeLista(lista *l)
{
lista *p = l;
if(listaVazia(l))
{
printf("Lista Vazia!!!\n");
}
else
{
do
{
printf(" | %d |", p->info);
p = p->prox;
}
while(p != l);
}
}
int main()
{
lista* l = (lista*)malloc(sizeof(lista));
l = criarLista();
l = inserirListaFim(l, 1);
l = inserirListaFim(l, 4);
l = inserirListaFim(l, 7);
imprimeLista(l);
return 0;
}
Which error message is reported by the compiler?
– Augusto Vasques
Process returned -1073741819 (0xC0000005)
– Guilherme Barbosa
I did the debugging and it’s in the instruction
imprimeLista(l);
that the system is stopping.– Augusto Vasques
Yeah, the problem is I can’t get this part
– Guilherme Barbosa