Thread: what is the difference between %# and % in printf

  1. #1
    Join Date
    Oct 2008

    what is the difference between %# and % in printf

    printf ("Some different radixes: %d %x %o %#x %#o \n", 100, 100, 100, 100, 100);

    %x shows 100 in hexadecimal basis


    but %#x makes some memory address out of it


    what does the addition of # ???

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    That's why you go to your friendly terminal screen and type man printf(or google, or the C standard, or heaven forbid, your textbook) and find this:
    Quote Originally Posted by ISO C,
    # The result is converted to an ‘‘alternative form’’. For o conversion, it increases
    the precision, if and only if necessary, to force the first digit of the result to be a
    zero (if the value and precision are both 0, a single 0 is printed). For x (or X)
    conversion, a nonzero result has 0x (or 0X) prefixed to it. For a, A, e, E, f, F, g,
    and G conversions, the result of converting a floating-point number always
    contains a decimal-point character, even if no digits follow it. (Normally, a
    decimal-point character appears in the result of these conversions only if a digit
    follows it.) For g and G conversions, trailing zeros are not removed from the
    result. For other conversions, the behavior is undefined.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. wats the fault...
    By ElemenT.usha in forum C Programming
    Replies: 17
    Last Post: 01-04-2008, 01:52 PM
Website Security Test