NEXT POINTER BINARY TREE

QUESTION: (https://www.interviewbit.com/problems/next-pointer-binary-tree/)
Given a binary tree

struct TreeLinkNode {
  TreeLinkNode *left;
  TreeLinkNode *right;
  TreeLinkNode *next;
}

Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL.

Initially, all next pointers are set to NULL.

   1
    / \ 
   2    3
      /
    4
     \
      5

WHAT SHOULD BE THE OUTPUT FOR SUCH A CASE?
shouldn’t 4 be pointing to 5 and 5 to null?
code: https://ide.codingblocks.com/s/264382
how do i handle the case when next to 4 is not null,like what are the changes required in line 17,instead of null to make 4 point to 5 instead of null

Hey, your code is falling for test case where a node has left child and not right child,also it has a next node and its next node has left child, then the current node left next should be equal to node’s next->left .But you are not setting it. I have added a code that handle this case.Also,i have added a link,please go through the link as well.

i couldnot get what you are trying to say,could you explain through the same example,what is missing?and could you suggest changes in my code only?