This code below does not work correctly, I type 5 nodes and was to return the number 5 (total number of nodes inserted). It turns out that I get 4.
int qtd_no_lista (tipo_lista * recebida)
{
tipo_lista * aux = recebida;
int cont=0;
while (aux -> prox != NULL)
{
aux = aux ->prox;
cont++;
}
printf("A quantidade de nos presente na lista e %d\n",cont);
return cont;
}
I think the error is in the line of while
, not sure, could help me.
It's decrementing, I think when I point to the next one it automatically decreases in total.
Please explain.