Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我必须在同一个函数中重用这段代码,但它不会工作,因为 res1->nextPtr 已经在链表的末尾。有没有办法将它重置为链表的“头”?
do { res1 = res1->nextPtr; }while(res1 != NULL);
LIST *head = res1; LIST *list = head; while (list) { //do something list = list->nextPtr; }; list= head; //again traverse over list
如果您的 res1 为 NULL,则您的 do-while 将出现段错误。