我想检查队列的所有元素,我试过这种方式,但它不起作用。
void search_queue(Queue* f) {
for(i = f->first; i!=NULL; i->next) {
printf("_");
}
}
我需要"数字"我队列中的所有页面
typedef struct page{
int number;
struct page* prox;
}Page;
typedef struct queue{
Page* first;
Page* end;
}Queue;
P.S:抱歉我的英语不好
答案 0 :(得分:0)
如果我正确理解您的代码,您会传递一个Queue
调用f
,该调用引用了队列的开头和结尾。从那里开始,您的目标是从头到尾打印队列中元素的数量。你实现队列的方式看起来好像只是通过链表进行简单的遍历。
void search_queue(Queue* q){
if(q == NULL){
/* If queue is empty */
return;
}
Page* current = q->first;
while(current != NULL){
printf("%d",current->number);
current = current->prox;
}
return;
}