Here is what I've done so far:

```
struct rep_list {
    struct node *head;
    struct node *tail;
}

typedef rep_list *list;

int length(const list lst) {
    if (lst->head == NULL) {
        return 0;
    }
    else {
        lst->head = lst->head->next;
        return 1 + length(lst);
    }
}

```

This works, but the head of the list the function accepts as a parameter gets changed. I don't know how to fix that.

I'm not allowed to change the function definition so it should always accept a list variable.

Any ideas?

EDIT: I tried to do what Tyler S suggested in the comments but I encountered another problem. If I create a node\* variable at the beginning, it should point to lst->head. But then every recursive call to the function changes the value back to lst->head and I cannot move forward.