However if the first digit of "inteiro" is a 0, this function doesnt count it. I wonder why?
(sorry about my eventual bad english)
sprintf() returns the length of the string it creates. So you use an int variable to capture that and then return it. However that is merely an efficiency.
The printf/sprintf/sscanf functions use format specifers that indicate the how the data should be displayed. In your case you a simple value of integer which will be the word size of the machine. At the same time since there is no "precision" the string will have zeroes supressed. You can definitely tell the printf() family of functions on how wide the string should be, and weather or not you want leading zeroes. For example, %5d would get you a five digit wide string that is zero supressed whereas %05D gives you the zeroes. You can also justify but beyond this, I highly recommend a good C text like K&R. These days you can probably download it as PDF.