/* Structure for a linked list*/
struct list{
   int num;
   struct list* next; /* pointer to next node in list*/
};
/* Function to split a linked list into two parts, given the position from which to start splitting*/
void split(struct list* head, struct list** dest, int position)
{
   int offset = 0;
   printf(“[%s][%d]\n”,__FUNCTION__,position);
   struct list* temp = NULL;
   struct list* newStart = NULL;
   while((offset < position -1) && (head->next != NULL))
   {
      head = head->next;
      offset++;
   }
   temp = head;  Â
   newStart = head->next;
   while(head->next != NULL)
   {
      *dest = head;
      head = head->next;
      (*dest) = (*dest)->next;
   }
   *dest = newStart;
   temp->next = NULL;
}
/* Function to use the linked list functions*/
int main()
{
   struct list* node = NULL;
   struct list* new = NULL;
   int i;
   for(i=0; i < 10; i++)
   {
      insert(&node,i);
   }
   split(node,&new,6);
   traverse(node);
   traverse(new);
   printf(“Old List length [%d]â€,length(node));
   printf(“New List Length [%d]â€,length(new));
}