Insert a Node at the Tail of a Linked List

  • + 6 comments

    I tried doing mine recursively in C any idea what went wrong?

    Node* Insert(Node *head,int data)
    {
        if(head->next==NULL)
            {
                Node *newn=(Node *)malloc(sizeof(Node));
                head->next=newn;
                newn->next=NULL;
                newn->data=data;
                return newn;
            }
        Insert(head->next,data);
        return head;
    }