title: Program produce Wrong output
body: <p>I have written a program on queues and dynamic memory allocation. This is what my program needs to do - insert values in to the queue and remove it from the queue; that simple. 
  But my problem is that it just prints the names of the variables the values are assigned to and the program goes not responding. </p>
  
  <p>Here is my program :</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #define MAX 180
  
  struct cakes{
          int spongecake;
          int meringue;
          int chocalate;
          int red_velvet;
          struct newcake *next;
  };
  
  struct Queue{
          int front;
          int rear;
          int count;
          int cake[10];
  };
  
  void init(struct Queue *);
  int isFull(struct Queue *);
  void insert(struct Queue *,int);
  int isEmpty(struct Queue *);
  int removes(struct Queue *);
  
  void cake_order(struct cakes *);
  void order_out(struct cakes *);
  
  main()
  {
          struct cakes *head;
  
          head=(struct cakes *)malloc(sizeof(struct cakes ));
          cake_order(&amp;head); //this is a seperate function and it works perfectly
          head-&gt;next=(struct cakes *)malloc(sizeof(struct cakes));
          order_out(&amp;head-&gt;next);
  }
  void init(struct Queue *q)
  {
          q-&gt;front=0;
          q-&gt;rear=10-1;
          q-&gt;count=0;
  }
  
  int isFull(struct Queue *q)
  {
          if(q-&gt;count==10)
          {
                  return 1;
          }
          else 
          {
                  return 0;
          }
  }
  
  void insert(struct Queue *q,int x)
  {
          if(!isFull(q))
          {
                  q-&gt;rear=(q-&gt;rear+1)%10;
                  q-&gt;cake[q-&gt;rear]=x;
                  q-&gt;count++;
          }
  
  }
  
  int isEmpty(struct Queue *q)
  {
          if(q-&gt;count==0)
          {
                  return 1;
          }
          else
          {
                  return 0;
          }
  }
  
  int removes(struct Queue *q)
  {
          int caked=NULL;
  
          if(!isEmpty(q))
          {
                  caked=q-&gt;cake[q-&gt;front];
                  q-&gt;front=(q-&gt;front+1)%10;
                  q-&gt;count--;
                  return caked;
          }
  }
  
  void order_out(struct cakes *order)
  {
          struct Queue s;
          int i;  
  
          order-&gt;spongecake=20;
          order-&gt;meringue=75;
          order-&gt;chocalate=40;
          order-&gt;red_velvet=30;
  
          init(&amp;s);
  
          for(i=0;i&lt;10;i++)
          {
                  insert(&amp;s,order-&gt;chocalate);
                  insert(&amp;s,order-&gt;spongecake);
                  insert(&amp;s,order-&gt;meringue);
                  insert(&amp;s,order-&gt;red_velvet);
      }
  
          while(!isEmpty(&amp;s)) 
          {   
                  printf("%d",removes(&amp;s));
          }
  }
  </code></pre>
  
  <p>What seems to be the problem here? 
  I am new to C, so yea am a bit slow when debugging in this language.</p>
  
  <p>Thank you for your time.</p>
  
  <p>Here is the output:</p>
  
  <p><img src="https://i.stack.imgur.com/bQErS.jpg" alt="enter image description here"></p>