problem with deleting node whose pointer is given (pointer to head not given)

I am writing a program of deleting a node (of a linked list) whose pointer is given. The program is given below:

  #include <stdio.h>     #include <stdlib.h>     struct Node {     int data;     struct Node* next;     };     // function to create linkedlist     void push(struct Node** headref, int newdata)     {     struct Node* newnode = (struct Node*)malloc(sizeof(struct Node));     (*newnode).data = newdata;     (*newnode).next = *headref;     *headref = newnode;     }     // function to delete node whose pointer is given     void nodedelete(struct Node* noderef)     {     int temp;     // swapping data with next node's data     temp=(*noderef).data;     (*noderef).data = (*((*noderef).next)).data;     (*((*noderef).next)).data = temp;     // deleting node...     (*noderef).next = (*((*noderef).next)).next;      } // Driver function     main()     {     struct Node* head = NULL;     push(&head,20);     push(&head,10);     push(&head,12);     push(&head,9);     push(&head,6);     push(&head,8);     printf("The original linked list is: ");     while(head!=NULL)     {     printf("%d->",(*head).data);     head=head->next;     }     nodedelete(head->next->next);     printf("\n The new linked list is: ");     while(head!=NULL)     {     printf("%d->",(*head).data);     head=head->next;     }     } 

It’s compiling but I am getting segmentation fault on running. Can anyone tell me where the error is?