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

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -