Thread: Displaying two digits with printf

  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    117

    Displaying two digits with printf

    I have an integer and if it is only 1 digit (1-9), I want there to be a 0 in front of it. Like displaying minutes. I tried just doing %2i, but it did not work. I also tried using the double and float signs (%2d and %2f) but neither of them worked. Is there a way I can do this?
    ex. 02: 05

  2. #2
    Registered User
    Join Date
    Jan 2010
    Posts
    34
    %02i must work

  3. #3
    Registered User
    Join Date
    Jun 2010
    Posts
    22
    giove is right... That will work

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 03-05-2009, 10:25 AM
  2. menu problem!!! need U R G E N T help!!!
    By catcat28 in forum C Programming
    Replies: 16
    Last Post: 11-19-2007, 01:32 PM
  3. Double to Int conversion warning
    By wiznant in forum C Programming
    Replies: 15
    Last Post: 09-19-2005, 09:25 PM
  4. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM
  5. Azbia - a simple RPG game code
    By Unregistered in forum Game Programming
    Replies: 11
    Last Post: 05-03-2002, 06:59 PM