I am using Objective-C and trying to create int values that are between 1-99 and if less than 10 I would like them to show as 01, 02, 03, 04, 05, etc. Can anyone tell me how to do that?
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Besides PengOne’s answer, you could also use a format string.
says ‘print the following int with at least 2 digits’ and will add the leading 0 if it only has one. It will print
Or if you want an NSString,