title: Simple linked list program just isn't working
body: <p>I'm just scratching the surface with nodes and linked lists, so I've been trying to create a linked lists that prints out nodes from 1-10. However, it's full of problems. The program gives me a runtime error and segmentation fault, I also have errors when running valgrind.</p>
  
  <p>The comments are more for me, to show that I (hopefully) know what each command is doing</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main(void) {
      typedef struct node {
          int value;
          struct node* next;
      }
      node;
  
      //creates nodes for head, tmp, content
      node* head = NULL;
      node* tmp = NULL;
      node* content = NULL;
  
      head-&gt;next = content; //head node points to content
  
      for (int i = 1; i &lt;= 10; i++) {
          content = malloc(sizeof(node)); //creates new node
          content-&gt;value = i; //node data becomes i
          tmp-&gt;next = content; //tmp node points to content node
          tmp = tmp-&gt;next; //tmp node becomes next content node
          content-&gt;next = NULL; //content node points to null
          printf("%i ", content-&gt;value); //see node value
      }
  
      while (head != NULL) {
          node* temp = head;
          head = head-&gt;next;
          free(temp);
      }
      return 0;
  }
  </code></pre>