Queues are usually implemented using linked lists since it's so much more efficient. Your queue can only ever process 10 items without having to keep shifting all the items in the array. Here's a quick queue I just whipped up for you:
Code:
itsme@itsme:~/C$ cat queue.c
#include <stdio.h>
#include <stdlib.h>
typedef struct queue_node_s
{
int num;
struct queue_node_s *next;
} QUEUE_NODE;
typedef struct
{
struct queue_node_s *head;
struct queue_node_s *tail;
} QUEUE;
void add_to_queue(QUEUE *q, int num)
{
QUEUE_NODE *new;
if(!(new = malloc(sizeof(QUEUE_NODE))))
{
puts("Memory allocation error!");
exit(EXIT_FAILURE);
}
new->num = num;
new->next = NULL;
if(q->tail)
{
q->tail->next = new;
q->tail = new;
}
else
q->head = q->tail = new;
}
void new_queue(QUEUE *q)
{
q->head = q->tail = NULL;
}
void destroy_queue(QUEUE *q)
{
QUEUE_NODE *n, *nnext;
for(n = q->head;n;n = nnext)
{
nnext = n->next;
free(n);
}
q->head = q->tail = NULL;
}
void print_queue(QUEUE *q, char *msg)
{
QUEUE_NODE *n;
printf("%s ", msg);
for(n = q->head;n;n = n->next)
printf("%d ", n->num);
putchar('\n');
}
void conc_queues(QUEUE *q1, QUEUE *q2)
{
if(q1->tail)
q1->tail->next = q2->head;
else
q1->head = q2->head;
q1->tail = q2->tail;
}
int main(void)
{
int nums[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int i;
QUEUE q1, q2;
new_queue(&q1);
new_queue(&q2);
for(i = 0;i < 5;++i)
add_to_queue(&q1, nums[i]);
for(;i < 10;++i)
add_to_queue(&q2, nums[i]);
print_queue(&q1, "Queue 1:");
print_queue(&q2, "Queue 2:");
conc_queues(&q1, &q2);
print_queue(&q1, "Concatenated:");
destroy_queue(&q1);
return EXIT_SUCCESS;
}
itsme@itsme:~/C$ ./queue
Queue 1: 1 2 3 4 5
Queue 2: 6 7 8 9 10
Concatenated: 1 2 3 4 5 6 7 8 9 10
itsme@itsme:~/C$
It can definitely be improved on, but it works.