I am trying to insert a new node at the end of the list. I know the first way is the "right way". But I am trying another way with another function (2nd function) like this but it seems there are not changes to my list, any thoughts?
typedef struct listnode *listptr;
struct listnode {
    int value;
    listptr next;
};
void insert_at_end(listptr *x, int n) {
    while ((*x) != NULL) {       
        x = &((*x)->next);   
    }                       
    *x = (listptr)malloc(sizeof(struct listnode));  
    (*x)->next = NULL;   
    (*x)->value = n;    
}
void insert_at_end_2(listptr x, int n) {
    listptr newnode = (struct listnode *)malloc(sizeof(struct listnode));
    newnode->next = NULL;
    newnode->value = n;
    while (x != NULL) {
        x = x->next;
    }
    x = newnode;
} 
 
     
    