title: creating linked List in c++
body: <p>I'm trying to create a linked list in c++ that inserts elements from the end. I have the following code</p>
  
  <pre><code>#include&lt;iostream&gt;
  
  using namespace std;
  
  //Define a structure
      struct Node{
          int info;
          Node* next;
      } *start, *newptr, *current, *ptr;
  
  Node* createNewNode(int);
  void insertEnd(Node*);
  void display(Node*);
  
  int main(){
      char ch='y';
      while(ch=='y')
      {
          int inf;
          //Initialize the start pointer to NULL
          start = NULL;
  
          //Prompt the user for information
          cout&lt;&lt;"Enter the information -&gt; ";
          cin&gt;&gt;inf;
  
          //Call the function to create a new node
          newptr = createNewNode(inf);
          cout&lt;&lt;"New node created successfully \n";
  
          //Insert the node in the beginning
          insertEnd(newptr);
  
          //Traversal
          display(start);
  
          //Asks the user for input
          cout&lt;&lt;"Want to enter more -&gt; ";
          cin&gt;&gt;ch;
      }
  
  
      return 0;
  
  }
  
  Node* createNewNode(int a)
  {
      ptr = new Node;
      ptr-&gt;info = a;
      ptr-&gt;next = NULL;
      return ptr;
  }
  
  void insertEnd(Node* p)
  {
      if(start == NULL){
          start = p;
          current = p;
      }else {
          current-&gt;next = p;
          current = p;
      }
  }
  
  void display(Node* p)
  {
      while(p!=NULL){
          cout&lt;&lt;p-&gt;info&lt;&lt;"-&gt;";
          p=p-&gt;next;
      }
  }
  </code></pre>
  
  <p>When I compile the program runs fine but it does not display the complete list. It only displays the number recently inserted in the list by the user. What's wrong with this code?</p>