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.
Here is my program :
#include <stdio.h>
#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(&head); //this is a seperate function and it works perfectly
        head->next=(struct cakes *)malloc(sizeof(struct cakes));
        order_out(&head->next);
}
void init(struct Queue *q)
{
        q->front=0;
        q->rear=10-1;
        q->count=0;
}
int isFull(struct Queue *q)
{
        if(q->count==10)
        {
                return 1;
        }
        else 
        {
                return 0;
        }
}
void insert(struct Queue *q,int x)
{
        if(!isFull(q))
        {
                q->rear=(q->rear+1)%10;
                q->cake[q->rear]=x;
                q->count++;
        }
}
int isEmpty(struct Queue *q)
{
        if(q->count==0)
        {
                return 1;
        }
        else
        {
                return 0;
        }
}
int removes(struct Queue *q)
{
        int caked=NULL;
        if(!isEmpty(q))
        {
                caked=q->cake[q->front];
                q->front=(q->front+1)%10;
                q->count--;
                return caked;
        }
}
void order_out(struct cakes *order)
{
        struct Queue s;
        int i;  
        order->spongecake=20;
        order->meringue=75;
        order->chocalate=40;
        order->red_velvet=30;
        init(&s);
        for(i=0;i<10;i++)
        {
                insert(&s,order->chocalate);
                insert(&s,order->spongecake);
                insert(&s,order->meringue);
                insert(&s,order->red_velvet);
    }
        while(!isEmpty(&s)) 
        {   
                printf("%d",removes(&s));
        }
}
What seems to be the problem here? I am new to C, so yea am a bit slow when debugging in this language.
Thank you for your time.
Here is the output:

 
     
     
    