title: Removing all nodes from a queue of structures
body: <p>I'm trying to delete all nodes from my queue of structures.</p>
  
  <p>Structure:</p>
  
  <pre><code>struct element{
  
      int id;
      int sign;
      int year;
      int month;
      double amount;
  
      struct element *next;
  };
  
  struct queue{
      struct element *head;  
  
      int size;
  };
  </code></pre>
  
  <p>And the function I wrote:</p>
  
  <pre><code>void delete(struct queue *queue) {
      if (queue-&gt;size == 0){
          printf("Structure is empty\n");
      }
      else {
          struct element* this;
          struct element* other;      
  
          for(this=queue-&gt;head;this!=NULL;this=other)
          {
              other=this-&gt;next;
              free(this);
          }
          free(queue);
      }   
  }
  </code></pre>
  
  <p>It doesn't work, and I'm out of ideas. Any suggestions?</p>