There are several ways depending upon what effect You want.
If it's because You want to have adjustable alignment of digits use the sprintf(Buffer,"%*u",Number_Of_Digits,Variable_To_Show).
If You want to make special tricks fill an array of strings with the descriptors and select the appropriate of them:
char * Descriptor[] = {"%3u","%03u","%-3u","%-03u"};
sprintf(Buffer,Descriptor[Index],Value_To_Show);
Be more specific if this does not cover it.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.