I have written two functions while learning Linked list. First counts and returns number of nodes in the list. Second adds new node towards the end of the list. Can you please help me understand why I need to use "current->next" to check for NULL in my code below in the addatend function? I did not have to use it for first function. Without that my exe crashes with bad pointer...

Thank you very much for your time and help.

```
int length(node * head) {
    node * current = head;
    int count = 0;

    while(current != NULL){  // This line works as expected....
        count ++;
        current = current->next;
    }
    return count;
}

void addatend (node * head, int value){
    node * newnode = (struct node *) malloc(sizeof(struct node));
    node * current = head;

    while (current != NULL){   // This line would not work?? If I use current->next != NULL it works.....
        current = current->next;
    }
    current->next = newnode;
    newnode->data = value;
    newnode->next = NULL;
}

```