co*******@gmail.com writes:
I am trying to understand why one of these crash while the other works
fine.
long recurssion(int t)
{
if(t <= 1)
return(1);
else
return(t * recurssion(t--)); //crashes
}
long recurssion(int t)
{
if(t <= 1)
return(1);
else
return(t * recurssion(t-1)); //works fine
}
Add this as the first statement of each function and try running it:
printf("Entering recurssion, t = %dl\n", t);
(BTW, the correct spelling is "recursion".)
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.