printf function changes int to char when using format specifier?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • vlsidesign

    #1

    printf function changes int to char when using format specifier?

    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?

  • user923005

    #2
    Re: printf function changes int to char when using format specifier?

    On Nov 14, 1:38 pm, vlsidesign <ford...@gmail. comwrote:
    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?
    Neither resembles something that is correct.

    man printf()
    The functions in the printf() family produce output according to a format as described below. The functions printf() and vprintf() write output to stdout, ...


    Or perhaps:


    Comment

    • Keith Thompson

      #3
      Re: printf function changes int to char when using format specifier?

      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_Keit h) kst-u@mib.org <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"

      Comment

      Working...