Without knowing what you mean by "trouble" it is difficult to make any suggestions.
However, what i see, is that you could optimize the code a little bit by better using the snprintf fomat options (if this is available with your implementation of snprintf).
printf("%d", 12) --> 12
printf("%d", 3) --> 3
printf("%02d", 12) --> 12
printf("%02d", 3) --> 03
where "0" tells printf to precede the number with "0" if required
and
2 tells printf the minimal number of digits to use.
Oliver