I would like to do a function to remove the first element from a linked list, the way I did it it is only removing the first node and removing the second element.
struct lista {
int info;
struct lista* prox;
};
typedef struct lista Lista;
Lista* removeInicio(Lista *l){
if(l->prox == NULL){
printf("Lista ja esta vazia\n");
return NULL;
}else{
Lista *tmp = l->prox;
l->prox = tmp->prox;
return tmp;
}
}
Edit: I have solved this algorithm.
Lista* removeInicio(Lista *l){
Lista* pointer = l->prox;
if(l->prox == NULL){
printf("Lista ja vazia\n\n");
return NULL;
}
l->prox = pointer-> prox;
free(pointer);
l->info--;}