此函数获取指向列表的“虚拟”项(第一项)的指针和一个struct
键入的“节点”以添加...
但它进入了一个无限循环......怎么了???
void listAdd(Node* dummy, Node tmpNode) {
Node* toAdd = (Node*)malloc(sizeof(Node));
*toAdd = tmpNode;
Node *tmp1,*tmp2;
tmp1 = dummy;
tmp2 = (*dummy).next;
while (tmp1 != NULL){
if ( ((*tmp1).info.id < (*toAdd).info.id && (*tmp2).info.id > (*toAdd).info.id ) || (tmp2==NULL) ) {
(*toAdd).next = (*tmp1).next;
(*tmp1).next = toAdd;
return;
}
tmp1 = (*tmp1).next;
tmp2 = (*tmp2).next;
}
}