Quantcast
Channel: Printing leading 0's in C - Stack Overflow
Viewing all articles
Browse latest Browse all 12

Printing leading 0's in C?

$
0
0

I'm trying to find a good way to print leading 0's, such as 01001 for a zipcode. While the number would be stored as 1001, what is a good way to do it?

I thought of using either case statements/if then to figure out how many digits the number is and then convert it to an char array with extra 0's for printing but I can't help but think there may be a way to do this with the printf format syntax that is eluding me.


Viewing all articles
Browse latest Browse all 12

Latest Images

Trending Articles



Latest Images