当我在main中调用printList函数时,它甚至没有打印出所有的值 值存在(我在printList函数中手动检查)
void printList(listNode *start)
{
listNode *currentPosition = start->next;
threadList *t;
t= currentPosition->tList->next;
cList *c;
c = currentPosition->tList->next->cpuList->next;
if (currentPosition == NULL)
{
printf("list is empty\n");
}
else
{
while (currentPosition != NULL)
{
printf("process #: %d # of thread: %d\n",currentPosition->processNumber,currentPosition->numThread);
while (t != NULL)
{
printf("thread #: %d Arrival time: %d # CPU: %d\n",t->threadNumber,t->arrivalTime,t->numCPU);
while (c != NULL)
{
printf("Burst #: %d CPU Time: %d io Time: %d\n",c->cNum,c->cpuTime,c->ioTime);
c=c->next;
}
t=t->next;
}
currentPosition = currentPosition->next;
}
}
}
我所有链表的第一个节点是虚节点。 有人可以帮我弄清楚我哪里出错了吗?
答案 0 :(得分:1)
在printList
中,您似乎最初设置了t
和c
,然后再也没有更新它们。
如果你移动
t= currentPosition->tList->next;
c = currentPosition->tList->next->cpuList->next;
到
的内部while (currentPosition != NULL) {
然后我认为它会起作用(我没有编译器方便)。