How can I write (using leading zeros)
(@"%d",9);
to be 00009 using a method that may exist in NS?
thanks
@LaC has a correct answer. But here's an interesting question: What if you don't know how many 0s you want?
Never fear, you can do this!
int numberOfZeros = 5;
NSLog(@"%0*d", numberOfZeroes, 9);
The "*" tells it to look for an extra int specifying the padding length. Neat, huh?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With