我放左個"return"入去
咁係唔係當個function行到return就會做完成個function,唔理之前recursion左幾多次?
e.g
我寫左一段code係咁:
member* search (member* find, char* name){
if(find){
if(strcmp(name,find->name)==0)
return find;
else{
search(find->left_child,name);
search(find->right_brother,name);
}
}
}
我係想用黎係一棵family tree入面
搵番一個岩名個parent
咁樣我呢個function係唔係一搵到岩名就會return個岩名既member既prointer, 而唔繼續搵落去?
thx
更新1:
咁我係唔係應該要加一句 member *tmp; tmp = (member*)malloc(sizeof(member)); 一話唔要malloc?