I am trying to print a linked list recursively. I created my own helper function for a recursive print, and I call it in my main print reverse function.
What happens is, my pointer to the head of the list will successfully go to the last element of the list, but it will crash. I am not too sure on what exactly is happening here. I have checked for out of bounds with my !=NULL. I am sort of lost on why it is not printing it backwards after the pointer has been established at the last integer. Here is my code.
void lst_recursion(NODE *p){
while (p != NULL){
lst_recursion(p->next);
printf(FORMAT, p->val);
}
}
void lst_print_rev(LIST *l) {
NODE *p = l->front;
printf("[");
while (p!= NULL){
lst_recursion(p);
}
printf("]\n");
}