Any ideea on how to do that? Something like break for a loop.
Any ideea on how to do that? Something like break for a loop.
A recursive function should only be broken when the base condition is met. So in your function you need to have an if test.
You could just stop recursing, and the stack would unwind.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Yea use a loop with a break statement.
Code:void recursiveFunction(arguments){ if(conditionMet) return; --- do something---- recursiveFunction(arguments); }
You can also use longjmp.
longjump ? what's that ?
It's like a global goto. I suggested it just as a joke, you shouldn't really use it unless you have to.