title: Using a for loop to create a linked list
body: <p>Newb C programmer here, assuming I have a struct for a node as follows</p>
  
  <pre><code>struct node{
  
      int data;
      struct node *next;
  
  };
  </code></pre>
  
  <p>How would I use a loop to make a linked list where the first node's data is 0, and a pointer to the next node whose data is 1. etc.</p>
  
  <p>EDIT:</p>
  
  <pre><code>int main(int argc, char* argv[]){
  
  struct node a;
  a.data = 0;
  
  struct node * tempnode = &amp;a;
  for (int i = 1; i &lt; 5; i++){
      struct node * next;
      next-&gt;data = i;
      tempnode-&gt;next = next;
      tempnode = next;
  }
  </code></pre>
  
  <p>Heres what i tried but it doesn't work</p>