I'm creating an array of queues and trying to initialize them by setting the fronts and backs to NULL. This works for the first two indexes (0 and 1) but if I go any further I just get a segmentation fault.
struct queue
{
struct node *front;
struct node *back;
};
struct node
{
struct node *next;
struct node *prev;
int sequenceNumber;
};
void init(struct queue *qPtr);
int main()
{
struct queue *theQueues[10];
init(theQueues[0]);
init(theQueues[1]);
init(theQueues[2]); // I am getting a problem on this line
}
void init(struct queue *qPtr)
{
qPtr->front = NULL;
qPtr->back = NULL;
}