title: Only first element prints, when printing linked list data
body: <p>I wrote this code for a user to enter the number of nodes they want in a list, as well as the element for each node. My error occurs only once I try printing the values of the list. It seems as though I am only printing the first value of the list. Either that or I was unsuccessful in assigning the data to the list. </p>
  
  <p>Note "list.h" only include the stdio and stdlib libraries, as well as the struct definition. Which just holds data and a pointer to the same struct.</p>
  
  <pre><code>#include "list.h"
  
  struct node *head = NULL;
  
  void print_data(){
  
    struct node* temp;
    temp = head;
  
    printf("\n\n");
  
    while(temp != NULL){
  
      printf("%d ", temp-&gt;data);
      temp = temp-&gt;next;
  
    }
  }
  
  void insert(data){
  
    struct node *temp = malloc(sizeof(struct node));
    struct node *p;
  
    temp-&gt;data = data;
    temp-&gt;next = NULL;
  
    if( head == NULL ){
  
      head = temp;
  
    }else{
  
      p = head;
  
      while( p-&gt;next != NULL){
  
        p = p-&gt;next;
        p-&gt;next = temp;
  
      }
    }
  }
  
  int main(){
  
    int i, amount, element;
  
    printf("\nEnter Amound of Nodes: \n");
    scanf(" %d", &amp;amount);
  
    for( i = 0; i &lt; amount; ++i){
  
      printf("\nEnter Node #%d amount ", i + 1);
      scanf(" %d", &amp;element);
      insert(element);
  
    }
  
    print_data();
  
  }
  </code></pre>