sprintf() might do that if you specify leading zeros.
The previous response is, however, way more efficient.