c - How to split a linked-list into two lists -
i'm writing code split circular linked-list 2 linked lists equal number of codes, following code: #include <stdio.h> #include <stdlib.h> typedef struct node *ptr; struct node { int element; ptr prev; ptr next; }; typedef ptr list; typedef ptr position; int main() { list l=malloc(sizeof(struct node)); list first=malloc(sizeof(struct node)); list second=malloc(sizeof(struct node)); splitlist(l,first,second); return 0; } void splitlist(list l, list first,list second) { position p,temp; p=malloc(sizeof(struct node)); temp=malloc(sizeof(struct node)); p=l; int count=0; while ((p)->next != l) { count++; } int c=count; while (c!=(count/2)-1) { p=(p)->next; temp=(p)->next; } first=l; (p)->next=null; second=temp; c=count; while (c!=(count/2)-1) { temp=(temp)->next; } (temp)->next=null; } when compiling code gives no er