title: Linked List: Segmentation fault
body: <p>I wanted to try out the example of a linked list on this page: <a href="http://www.codeproject.com/Articles/24684/How-to-create-Linked-list-using-C-C" rel="nofollow">How to create Linked List using C++</a>.<br>
  This is my code so far:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace s-td;
  
  class node {
  public:
      int value;
      node *next;
  };
  
  int main() {
      node *head = nullptr;
  
      node *temp1;
      temp1 = new node();
      temp1-&gt;value = 1;
      temp1 = head;
  
      while(temp1-&gt;next!=nullptr) {
          temp1 = temp1-&gt;next;
      }
      return 0;
  }
  </code></pre>
  
  <p>But unfortunately I get a <code>Segmentation fault</code>.
  I think this part is faulty:</p>
  
  <pre><code>while(temp1-&gt;next!=nullptr) {
      temp1 = temp1-&gt;next;
  }
  </code></pre>