title: Linked List - undo move works only once, not twice in a row for my mini game
body: <p>Hey I'm working on my mini game and it is very similar to 2048, but it comes with board size opinion (4x4 to 12x12). However, I'm working on undo move code. The problem is when the game goes on, when I undo the move and try to do it again, it only works for the previous move, not goes back to 2nd previous move from the current move. For example:</p>
  
  <p>Score: 0
     .   .   .   .</p>
  
  <p>2   .   .   .</p>
  
  <p>.   .   2   .</p>
  
  <p>.   .   .   .
  1. Your move: u
  <em>*</em> You cannot undo at the beginning of the game. Retry.
  1. Your move: a</p>
  
  <p>Score: 0</p>
  
  <p>.   .   4   .</p>
  
  <p>2   .   .   .</p>
  
  <p>2   .   .   .</p>
  
  <p>.   .   .   .
  2. Your move: s</p>
  
  <p>Score: 4
     .   .   .   .</p>
  
  <p>.   .   .   .</p>
  
  <p>.   2   .   .</p>
  
  <p>4   .   4   .
  3. Your move: u</p>
  
  <p>Score: 0
     .   .   4   .</p>
  
  <p>2   .   .   .</p>
  
  <p>2   .   .   .</p>
  
  <p>.   .   .   .
  2. Your move: u</p>
  
  <p>Score: 0
     .   .   .   .</p>
  
  <p>2   .   .   .</p>
  
  <p>.   .   2   .</p>
  
  <p>.   .   .   .
  2. Your move: u <strong>(THE PROBLEM HERE)</strong></p>
  
  <p>Here is my code:</p>
  
  <pre><code>    struct Node
  {
      int *board;
      int move;
      int score;
  
      Node *pNext;
  };
  
  //to store the node in the board to create the linked list.
  void newNode(Node* &amp;pHead, int *board, int move, int score, int size)
  {
     Node *pTemp = new Node();
  
     //copy the board into pTemp
     pTemp-&gt;board=new int[size*size];
  
     for(int i=0; i &lt; size*size; i++) 
     {
          pTemp-&gt;board[i] = board[i];
     }
  
     // to copy the move number and score into pTemp
     pTemp -&gt; move = move;
     pTemp -&gt; score = score;
  
     //Connect the pTemp into the list and update the head of the list
     pTemp-&gt;pNext = pHead;
     pHead = pTemp;
  }//end newNode()
  
  
  //delete move node function
  void deleteMove(Node* &amp;pHead, int *board, int &amp;move, int &amp;score, int size)
  {
     // to make sure we have at the original node on the list
     if(pHead -&gt; pNext != NULL) 
     {
  
          // The node has the current board.  Delete this one and go back to the
          // one before that.
          Node *pTemp = pHead;
          pHead = pHead -&gt; pNext;
          delete (pTemp -&gt; board);
          delete(pTemp);
  
          // copy the board from the previous Node into the current display
          for(int i = 0; i &lt; size*size; i++) 
          {
              board[i] = pHead-&gt;board[i];
          }
  
          //delete the move number and number from the Node
          move = pHead -&gt; move;
          score = pHead -&gt; score;
     }
  }
  </code></pre>