title: I keep recieving a collect2: error: ld returned 1 exit status
body: <p>I am having a bit of a problem. I keep receiving a "collect2: error: ld returned 1 exit status" every time I try to compile my program. I googled this, looked at examples, and saw that it usually occurs when a header file is not used correctly; however, I did not use header files in my code so I am not sure why it is doing this. I think this would be helpful for others who get this error and don't understand why. I do know that there are a lot of errors in my code, but I am trying to get to where I can compile it and work out all the kinks. Thanks a bunch!!</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  struct node_t {
      double x;
      struct node_t *next;
  };
  
  struct node_t *create_node(double n);
  void print_node (struct node_t * node ); 
  void print_list (struct node_t * head );
  struct node_t * insert_head (struct node_t *head , struct node_t * node );
  struct node_t * insert_tail (struct node_t *head , struct node_t * node );
  struct node_t * insert_middle (struct node_t *head , struct node_t *node , int pos );
  int count_nodes (struct node_t * head );
  struct node_t * delete_node (struct node_t *head , double n);
  void delete_list (struct node_t * head ); 
  
  int main (void) 
  {
  
      double n;
      int pos;
  
  
  /** Asks the user what they would like to do. */
  
      printf("Please select an option: ");
      printf("1. Enter a number ");
      printf("2. Delete a number ");
      printf("3. Print all numbers ");
      printf("4. Tell how many items in the list ");
      printf("5. End program ");
      printf("Please enter your choice (1, 2, 3, 4, 5): ");
      while ((tmp = getchar()) != '\n')
          in = tmp; /** Tells the compiler to use the number that the use put in. */
  
      switch (in){
      case '1': {/** If the user chooses Enter a Number, go through this process. */
          printf("1. Enter item at head of list ");
          printf("2. Enter item in middle of list ");
          printf("3. Enter item at tail of list ");
          printf("Please enter your choice (1,2,3): ");
          while ((tmp = getchar()) != '\n')
              in = tmp;
  
          switch (in) {
          case '1':{
              printf("Enter the number to be entered at head: ");
  
              fgets(s, 1024, stdin);
  
              struct node_t * create_node (double n);
              struct node_t *insert_head(struct node_t *head, struct node_t *node);
  
              break;
              }
  
          case '2':{
              printf("Enter the number to be entered in middle: ");
  
              fgets(s, 1024, stdin);
  
              struct node_t * create_node (double n);
              struct node_t * insert_middle (struct node_t *head , struct node_t *node , int pos);
              break;
              }
  
          case '3':{
              printf("Enter the number to be entered at tail: ");
  
              fgets(s, 1024, stdin);
  
              struct node_t * create_node (double n);
              struct node_t *insert_tail(struct node_t *tail, struct node_t *node);
  
              break;
              }
          break;
              }
          }   
  
      case '2':{/** If the user selected Delete a Number, go through this process. */ 
  
          printf("Enter the node that needs to be deleted: ");
  
          fgets(s, 1024, stdin);
  
          struct node_t * delete_node (struct node_t *head , double n);
  
          break;
  
          }   
  
      case '3':{/** If the user selected Print All Numbers, go through this process. */
  
          //void print_list (struct node_t *head)
  
          break;
  
          }
  
      case '4':{ /** If the user selected Tell How Many Items in the List, go through this process. */
          int count_nodes (struct node_t * head );        
  
          break;
          }
  
      case '5':{ /** If the user selected End Program, go through this process. */
  
          return 1;       
  
          break;
          }
  
      }       
  
      return 0;
  
  }
  
  
  
  
  
  
  
  /** Creates a new node
   *  @param double n, a number n
   *  @return pointer
   */
  
  struct node_t * create_node (double n)
  {
  
  
      struct node_t *p = malloc (size of (struct node_t))
      p -&gt; x = n;
      p -&gt; next = NULL; /*initializes pointer to null*/
      return p;
  }
  
  
  /** Prints the nodes
   *  @param struct node_t *node
   */
  //void print_node (struct node_t *node )
  //{
  //  prints out the node and the address of the node
  //  print(*node, &amp;node)
  //}
  
  
  /** Prints list
   *  @param struct node_t *head
   */
  //void print_list (struct node_t *head)
  //{
  //  print contents of list. both the doubles and the address.
  //  while (pointer is pointing to something, keep going through the list. )
  //  print(nodes in list, address of nodes )
  //}
  
  
  /** Inserts a node at the head
   *  @param struct node_t *head, the structure where head is. 
   *  @param struct node_t *node, the structure where node is.
   *  @return head.
   */
  struct node_t *insert_head(struct node_t *head, struct node_t *node)
  {
      node-&gt; next = head;
      head = node;
      return head;
  }
  
  
  /** Inserts a node at the tail.
   *  @param struct node_t *tail, the structure where tail is. 
   *  @param struct node_t *node, the structure where node is.
   *  @return head.
   */
  struct node_t *insert_tail(struct node_t *tail, struct node_t *node)
  {
  
      struct node_t *p = head;
      if (head == NULL)
          head = node;
          return head;
      while (p-&gt;next ! = NULL)
          p = p-&gt; next;
          p-&gt; next = node;
          return head;
  }
  
  
  /** Inserts a node at the middle.
   *  @param struct node_t *head, the structure where head is. 
   *  @param struct node_t *node, the structure where node is.
   *  @param int pos, the position of the current node.
   *  @return head.
   */
  struct node_t * insert_middle (struct node_t *head , struct node_t *node , int pos);
  {
  
      int pos = 1;
      struct node_t *p = head;
      *head = pos, pos = 1;
      if (pos &gt; SIZE )
          p-&gt; next = node;
      else if (pos &lt; 1)
          printf("Error\n");
      return head;
  }
  
  
  /** Counts the number of nodes
   *  @param struct node_t *head, the structure where head is. 
   *  @return count.
   */
  int count_nodes (struct node_t * head );
  {
  
      struct node_t *p = head;
      while(p-&gt;next ! = NULL)
          return count;
      if (head == NULL)
          count = 0;
      return count;
  }   
  
  /** Deletes nodes
   *  @param struct node_t *head, the structure where head is. 
   *  @param double n, a number n.
   *  @return head.
   */ 
  struct node_t * delete_node (struct node_t *head , double n);
  {
  
      if (node == head)
          free head;
          p-&gt;next = head; //head now points to the pointer that was next after the node that was deleted
  
      else if (node == middle)
          free node;
          p = p-&gt;next //pointer before node that was deleted now points to node that was after deleted node
  
      else if (node == tail)
          free p = p-&gt;next = node; //free the last node that holds data. The node before it now points to NULL
          p-&gt;next = NULL;
  
      else printf("Error\n")
      return head;
  }
  
  
  /** Deletes list
   *  @param struct node_t *head, the structure where head is. 
   *  @return head.
   */ 
  void delete_list (struct node_t * head ); 
  {
      while((p-&gt;next ! = NULL)
          free head; //This will lose all memory after head.
          head == NULL;
      if (head == NULL) 
          return 0;
      return 0;
  }
  </code></pre>