void add(llist *list, lnode *newNode){
list->size++;
addRecursion(&list->head, newNode);
}
lnode* addRecursion(lnode **node, lnode *newNode){
if(*node == NULL){
*node = newNode;
}
else{
lnode *nextNode = (*node)->next;
(*node)->next = addRecursion(&nextNode, newNode);
}
return *node;
}
This code works fine.. I took a look at the codes online and made a few changes. But I still don t understand that why addRecursion function has to have the return type. I changed the function like
void addRecursion(lnode **node, lnode *newNode){
if(*node == NULL){
*node = newNode;
}
else{
lnode *nextNode = (*node)->next;
addRecursion(&nextNode, newNode);
}
}
然后,它就没有工作。