Skip to main content

Format string, integer with leading zeros





NSString* strName = [NSString stringWithFormat:@"img_00%d.jpg", pp];







and works fine, but if pp took the value of 10 for example I wish have img_010.jpg as result, and not img_0010.jpg... how can I format the string??





thanks


Comments

  1. Use the format string "img_%03d.jpg" to get decimal numbers with three digits and leading zeros.

    ReplyDelete

Post a Comment

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?