当我在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 emptyn");
}
else
{
while (currentPosition != NULL)
{
printf("process #: %d # of thread: %dn",currentPosition->processNumber,currentPosition->numThread);
while (t != NULL)
{
printf("thread #: %d Arrival time: %d # CPU: %dn",t->threadNumber,t->arrivalTime,t->numCPU);
while (c != NULL)
{
printf("Burst #: %d CPU Time: %d io Time: %dn",c->cNum,c->cpuTime,c->ioTime);
c=c->next;
}
t=t->next;
}
currentPosition = currentPosition->next;
}
}
}
所有链表中的第一个节点是一个虚拟节点。有人能帮我弄清楚我错在哪里吗?
在printList
中,看起来您最初设置了t
和c
,然后从不更新它们。
移动
t= currentPosition->tList->next;
c = currentPosition->tList->next->cpuList->next;
放到
里面while (currentPosition != NULL) {
然后我认为它会工作(我手边没有编译器)。