SIGSEGV error in linked-list swapping

Got SIGSEGV error in this function which basically swaps every two numbers

void swap(struct node *head){
 if(head == NULL || head->next == NULL)
	return;

 struct node *temp = head,*temp1 = head->next,*ptr,*start = NULL;
 while(temp1 != NULL){
	temp->next = temp1->next;
	temp1->next = temp;

	if(start == NULL)
		start = temp1;
	else
		ptr->next = temp1; 
	ptr = temp;	

	temp = temp->next;
	temp1 = temp->next;
	display(start);
 }
}

Ideone link

see this corrected code…link!!!

Stupid Mistake but thanks anyway :slight_smile:

hehe…glad could help…:stuck_out_tongue: :slight_smile: