0
I’m trying to make a linked list with insertion at the end of it, but at the time of writing the error and I don’t know what the problem is.
#include <stdio.h>
#include <stdlib.h>
struct cel
{
int v;
struct cel *prox;
};
typedef struct cel celula;
int main()
{
celula *inicio;
inicio = NULL;
inserefim(&inicio);
escreve(inicio);
return 0;
}
void inserefim(celula **ini)
{
celula *aux;
celula **fim;
int x;
do{
scanf("%d",&x);
if(x)
{
if(*ini == NULL){
aux =(celula*) malloc(sizeof(celula));
aux->v = x;
aux->prox = NULL;
*ini = aux;
*fim = aux;
}else{
aux = (celula*)malloc(sizeof(celula));
aux->v = x;
(*fim)->prox = aux;
aux->prox = NULL;
}
}
}while(x);
}
void escreve(celula *ini)
{
while(ini =! NULL)
{
printf("\nNUM:%d",ini->v);
ini= ini->prox;
}
}
And what is the error message?
– Woss