printf function changes int to char when using format specifier?

Discussion in 'C Programming' started by vlsidesign, Nov 14, 2007.

  1. vlsidesign

    vlsidesign Guest

    Example
    printf("I have %d cars. \n", 10);

    Is it more correct to say that the printf function doesn't insert the
    integer, rather into changes the integer into chars and then inserts
    it?
     
    vlsidesign, Nov 14, 2007
    #1
    1. Advertising

  2. vlsidesign

    user923005 Guest

    user923005, Nov 14, 2007
    #2
    1. Advertising

  3. vlsidesign wrote:
    > Example
    > printf("I have %d cars. \n", 10);
    >
    > Is it more correct to say that the printf function doesn't insert the
    > integer, rather into changes the integer into chars and then inserts
    > it?


    printf inserts (into the stdout output stream) a textual representation of the
    int value 10.

    It doesn't change the integer into anything; 10 is still an integer. Rather, it
    computes a sequence of characters {'1', '0'} from the integer.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    Looking for software development work in the San Diego area.
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, Nov 14, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Schnoffos
    Replies:
    2
    Views:
    1,247
    Martien Verbruggen
    Jun 27, 2003
  2. Hal Styli
    Replies:
    14
    Views:
    1,697
    Old Wolf
    Jan 20, 2004
  3. Money
    Replies:
    18
    Views:
    700
    Jack Klein
    Jun 24, 2006
  4. jayapal
    Replies:
    7
    Views:
    649
    Army1987
    Oct 30, 2007
  5. asit
    Replies:
    8
    Views:
    419
    Martin Ambuhl
    Jan 13, 2008
Loading...

Share This Page