silly printf("%d", var) question

This is a discussion on silly printf("%d", var) question within the C Programming forums, part of the General Programming Boards category; It's been a long time since I don't use printf that i almost forgot it. Code: int var = 8; ...

  1. #1
    Registered User
    Join Date
    Nov 2006
    Location
    japan
    Posts
    126

    Talking silly printf("%d", var) question

    It's been a long time since I don't use printf that i almost forgot it.

    Code:
    int var = 8;
    printf("%d", var);
    gives me

    Code:
    8
    but I want 2 digit 8, I know it was something between "%" and "d" but i cannot remember.
    something like:
    Code:
    08
    Mac OS 10.6 Snow Leopard : Darwin

  2. #2
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,057
    Code:
    printf("%02d", var);

  3. #3
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Feel free to look at this

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A silly question but it's my doubt ;)
    By chottachatri in forum C++ Programming
    Replies: 19
    Last Post: 04-23-2008, 02:26 PM
  2. Really quick silly question.
    By Jozrael in forum C++ Programming
    Replies: 36
    Last Post: 04-04-2008, 09:31 AM
  3. silly client server question
    By geek@02 in forum Windows Programming
    Replies: 10
    Last Post: 12-03-2007, 05:23 AM
  4. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM
  5. Very simple question, problem in my Code.
    By Vber in forum C Programming
    Replies: 7
    Last Post: 11-16-2002, 03:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21