title: reverse a linked list?
body: <p>Im trying to reverse the order of the following linked list, I've done so, But the reversed list does not seem to print out. Where have I gone wrong?   </p>
  
  <pre><code>//reverse the linked list
      #include &lt;iostream&gt;
      using namespace std;
  
      struct node{
          int number;
          node *next;
      };
  
      node *A;
  
      void addNode(node *&amp;listpointer, int num){
          node *temp;
          temp = new node;
          temp-&gt;number = num;
          temp-&gt;next = listpointer;
          listpointer = temp;
      }
  
      void reverseNode(node *&amp;listpointer){
          node *temp,*current;
          current = listpointer;
          temp = new node;
          while (true){
              if (current == NULL){
                  temp = NULL;
                  break;
              }
              temp-&gt;number = current-&gt;number;
              current = current-&gt;next;
              temp = temp-&gt;next;
          }
          listpointer = temp;
      }
  
      int main(){
          A = NULL;
          addNode(A,1);
          addNode(A,2);
          addNode(A,3);
  
          while (true){
              if (A == NULL){break;}
              cout&lt;&lt; A-&gt;number &lt;&lt; endl;
              A = A-&gt;next;
          }
          cout&lt;&lt; "****" &lt;&lt; endl;
          reverseNode(A);
  
          while (true){
              if (A == NULL){break;}
              cout&lt;&lt; A-&gt;number &lt;&lt; endl;
              A = A-&gt;next;
          }
  
          cout&lt;&lt; "****"&lt;&lt; endl;
  
          return 0;
      }
  </code></pre>