您可以返回错误代码,或修改一些全局变量,以便每个递归实例都知道可以“杀死自己”。
某种东西。
int foo(bar){ int to_the_next; if (go_recursive){ to_the_next = foo(whisky_bar); if (to_the_next ==DIE) return DIE; } if (something_unexpected_happened) return DIE; process;//may include some other recursive calls, etc etc}


