C18 sprintf

AtomSoft

Well-Known Member
Hey guys just want to ask what could be a simple question. Im using sprintf to output numbers into string format which is working well.

But i would like 2 characters. Like when i have a char and the number is anywhere from 0 to 9 i get 0 to 9 but i would like to get 00-09.. get it?

I usually get:
0
1
2
3
4
5
6
7
8
9
10 - FIRST 2 CHARACTERS

I would like:

00
01
02
03
04
05
06
07
08
09
10

Is it possible to some how force this in sprintf? or should i simply:

Code:
			if(Data< 10){
				sprintf(Data2,"0%d\0",Data);
			} else {
				sprintf(Data2,"%d\0",Data);
			}
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…