我需要一个全局结构,它定义了一个队列数组。我想用教育目的的指针。 内部A.H我所定义的结构队列:全局变量和结构数组
typedef struct Queue
{
int size;
q_elem *root;
q_elem *last;
} Queue;
和外部可变
extern Queue **queue;
交流转换器所具有的功能队列* queue_new()来创建一个新的队列。
现在b.c使用全局变量Queue ** queue;我想创建一个队列数组。
我想什么:
queue = calloc(num_queues, sizeof(Queue*));
int i;
for(i=0; i < num_queues; i++){
queue[i] = queue_new();
}
但它似乎没有当我检查我的调试器中正常工作。我究竟做错了什么?
Queue* queue_new() {
Queue *newQ = (Queue*) malloc(sizeof(Queue));
if (newQ == NULL)
return NULL;
*newQ = (Queue) {0, NULL, NULL};
return newQ;
}
它是如何不起作用是否正确? – user694733
当我检查调试器内部时,_it的含义似乎并不正确。 – Rohan
我认为这可能是你在queue_new() – Marco