Shuffle merge of two linked lists

/* Program to merge two linked lists  */

    #include
    #include
    struct link
        {
            int info;
            struct link *next;
        };
    typedef struct link node;   
    void create(node **ptr)
        {
            node *temp;
            temp=*ptr;
            char ch;
            do
            {
                printf("Enter data : " );
                scanf("%d",&temp->info);
                printf("Want to add more ?(y/n) : ");
                scanf("%s",&ch);
                if(ch=='y')
                    {
                        temp->next=(node *)malloc(sizeof(node));
                        temp=temp->next;
                    }
            }    while(ch=='y');
            temp->next=NULL;
        }
    void merge(node **ptr1,node **ptr2)
        {
            node *prev1,*prev2;
            node *current1=*ptr1;
            node *current2=*ptr2;                       
            while(current1!= NULL || current2!= NULL)
                {
                    prev1 = current1;
                    prev2 = current2;
                    current1 = current1->next;
                    current2 = current2->next;
                    if(prev1->next == NULL)
                        {
                            prev1->next = prev2;
                            break;
                        }
                    else if(prev2->next==NULL)
                        {
                            prev1->next = prev2;
                            prev2->next = current1;
                            break;
                        }
                    else
                        {
                            prev1->next = prev2;
                            prev2->next = current1;
                        }
                }
        }

    void display(node *ptr)
    {
        while(ptr!=NULL)
        {
            printf(" %d --> ",ptr->info);
            ptr=ptr->next;
        }
        printf("\b\b\b\b   ");
    }
    main()
        {
            printf("\nPROGRAM TO MERGE TWO LINKED LISTS : \n");   
            node *head1,*head2;
            head1=(node *)malloc(sizeof(node));
            head2=(node *)malloc(sizeof(node));
            printf("\nEnter data for list 1 : \n");           
            create(&head1);
            printf("\nEnter data for list 2 : \n");
            create(&head2);
            printf("\nLinked list 1 : ");
            display(head1);
            printf("\n\nLinked list 2 : ");
            display(head2);
            merge(&head1,&head2);
            printf("\n\nMerged Linked list : ");
            display(head1);
            printf("\n\n\n");
        }

Top