title: Moving a certain node in a linked list forward n positions
body: <p>I'm trying to move a node forward n positions in a linked list</p>
  
  <p>e.g</p>
  
  <p>list : 1, 2, 3, 4, 5, 6</p>
  
  <p>Moving '2' forward 3 positions</p>
  
  <p>New list: 1, 3, 4, 5, 2, 6</p>
  
  <p>This is what I tried</p>
  
  <pre><code>void MoveNodeForward(Node* head, int x, int n)
  {
      Node* t = head;
  
      while(t != NULL)
      {
          if(t-&gt;data == x)
          {
              for(int i=0; i&lt;n &amp;&amp; t-&gt;next != NULL; i++)
              {
                  int temp = t-&gt;next-&gt;data;
                  t-&gt;next-&gt;data = t-&gt;data;
                  t-&gt;data = temp;
                  t = t-&gt;next;
              }
          }
  
          t = t-&gt;next;
      }
  
  }
  </code></pre>
  
  <p>But it just swaps the value of the nodes.</p>
  
  <p>I need a way to change the position of the node itself not just the value.</p>