Quantcast
Viewing all articles
Browse latest Browse all 12

Answer by EvilTeach for Printing leading 0's in C?

printf("%05d", zipCode);

The 0 indicates what you are padding with and the 5 shows the length of the integer number. For example if you use "%02d" (Useful for dates) this would only pad zeros for numbers in the ones column ie.(06 instead of 6). Example 2, "%03d" would pad 2 zeros for one number in the ones column and pad 1 zero for a number in the tens column. ie. (number 7 padded to 007 and number 17 padded to 017).


Viewing all articles
Browse latest Browse all 12

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>