i have a full linked list with data in it, what i want is to fill another linked list with the same data but with a condition, so let say that this is the linked list :
char cl; 
int time; 
int lng;
C 0 1
D 0 2
B 2 1
A 2 2
i wan to copy from this list to a new empty one but only if (time>0), so the new one will be like this :
B 2 1
A 2 2
i have tried this code but it doesn't work :
void insert(const node * n )// this where i put the pointer of the full node
{
    node *head=n;
    node *sec; // new node
    sec=(node*)malloc(sizeof(node)); 
    do{
        if(head->time>0){
            strcpy(sec->cl,head->cl);
            sec->time= head->time;
            sec->lng= head->lng;
            head=head->next;
            sec=sec->next;
        }
        else 
            head=head->next;
    }while(head!=NULL);
    print(sec) // this will print the new node
}
Help me please. Thank you
 
     
     
    