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

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -