title: My program stops working from a while loop when using dynamic allocated lists
body: <p>I've been studying about dynamic allocated lists (the stuff we are discussing right now in class is pretty outdated tbh) and I can't seem to access the next node in a list. (I've just began learning this topic)</p>
  
  <p>The problem is that the while loop that I'm using for going through the list never stops. I'm definitely missing something and I don't understand what.</p>
  
  <pre><code>struct node {
      int info;
      node* next;
  };
  
  int main()
  {
      node *p, *prim=NULL;
      p = prim;
      node* t;
      t = new node;
      p-&gt;next = t;
      while (p != NULL)
      {
          cout &lt;&lt; "test";
          p = p -&gt; next;
      }
      return 0;
  }
  </code></pre>
  
  <p>Here is the code.</p>
  
  <p>Why does my program not output anything and also tells me "it exited with code -1073741819" instead of 0? </p>
  
  <p>Thanks.</p>
  
  <p>////edit: I forgot to tell you that I've tried this way too</p>
  
  <pre><code>struct node {
      int info;
      node* next;
  };
  
  int main()
  {
      node *p, *prim=NULL;
      p = prim;
      node* t;
      t = new node;
      prim-&gt;next = t;
      while (p != NULL)
      {
          cout &lt;&lt; "test";
          p = p -&gt; next;
      }
      return 0;
  }
  </code></pre>