AS whiteflags said, there is a difference between pre and post decrement.
Because of that difference, your first is (roughly) functionally equivalent to
Code:
int fact(int x)
{
if(x == 1)
return 1;
else
{
return x * fact(x);
--x;
}
}
which is infinitely recursive (and decrementing of x is never executed). The second is functionally equivalent to
Code:
int fact(int x)
{
if(x == 1)
return 1;
else
{
--x;
return x * fact(x);
}
}
which, because it decrements x BEFORE calling fact() recursively, is not infinitely recursive.
Note that your second version will also be infinitely recursive if supplied with a negative argument.