title: Doubly linked list wont work
body: <p>When i run this, it doesn't report any errors, but nothing actually happens. It wont return the pointer to smallest element of the list, it just do nothing.</p>
  
  <p>Make a function with pointer that points to the first element of the doubly 
  linked list, that returns the pointer to the smallest element of the list</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  
  typedef struct list DLlist;
  
  struct list{
      DLlist *next, *previous;
      int number;
  };
  
  DLlist *first = NULL;
  
  int n=0;
  
  DLlist* add(DLlist *end, int number){
  
  DLlist* perm;
      perm = (DLlist *)malloc(sizeof(DLlist));
      perm-&gt;number = number;
  
  
  if(first==NULL){
          first = perm;
          first-&gt;next = NULL;
          first-&gt;previous = NULL;
          end = perm;
  }else{
  
      perm-&gt;next = NULL;
      end-&gt;next = perm;
      perm-&gt;previous = end;
      end = perm;
      return end;
      n++;
  
      }
  
  }
  
  DLlist* return_smallest(DLlist *first){
      DLlist *max;
      DLlist *current;
      first = max;
      current = first;
  
  for(int i=0;i&lt;n;i++){
          if(current-&gt;number &lt; max-&gt;number) max = current;
          current = current-&gt;next;
      }
      return max;
  }
  
  void main(){
  
      DLlist *end = NULL;
  
      int number;
      int choice;
  
  do{
      printf("1-Add elements to list: \n"
             "2-Return a pointer to the smallest element in the list\n");
      scanf("%d",&amp;choice);
      scanf("%d",&amp;number);
  
  switch(choice){
      case 1: end = add(end, number);break;
      case 2: printf("%d",(return_smallest(first))-&gt;number);
      }
  
  }while(choice == 1);
  }
  </code></pre>