I trying to insert a node at the tail end of a linked list. But when I am moving the tail pointer to point to the new node I am getting an error of segmentation fault.

Also I am not able to print the current value of the tail's next value, which should be NULL.

I am using gcc in mac enviroment.

```
 void insert_tail(int val,struct node **tail)
 {
    struct node *new_node=NULL;
    new_node=malloc(sizeof(*new_node));
    new_node->data=val;
    //printf("%p",(void*)*(*tail)->next);
    *(*tail)->next=*new_node;
    *tail=new_node;
 }

```

I am not getting any error when I run the same code on Visual C.

Please help me resolve this.