c - Incrementing an argument and recursion -
void base_aux(unsigned int n, unsigned int base, unsigned int x) { if (n > (base - 1)) { printf("%u", n % base); base_aux(n / base, base, x++); } else { printf("%u", n); zero_int(32 - x); printf("\n %d \n", x); } }
so, i'm trying see why x
isn't incrementing. stays @ 0 when call zero_int
. reason why? how fix this?
when do
foo(x++);
it equivalent to
temp = x; x = x + 1; foo(temp);
so can x++
returns x
, increments x
. called postfix increment.
so in code keep call function same value of x
if do
foo(++x);
it equivalent to
x = x + 1; temp = x; foo(temp);
so can ++x
increments x
, returns x
. called prefix increment.
Comments
Post a Comment