stdio alignment?

Is there a way in stdio to align my text?

Something like this:
1
2
3
4
int i = 1;
int b = 21;
printf("num:  %align(i)",6);
printf("num:  %align(b)",6);


That would print out:

num: 1
num:21


Or at least something similar that would have similar effects?
printf ( "num: %2d", i ); or printf ( "num: %*d", 2, i );
where 2 is the max number of spaced to add
Last edited on
Thankyou :) I love this website
Also can you do the same thing with strings too?
Yes
ok finished

printf("%3d : %6s \n",i+1,color[i]);
you can also use minus symbol to make things left justified. %-3d %-30s
you can also set number of decimals for doubles/floats . %0.3d
Topic archived. No new replies allowed.