hw does printf(),scanf() nd all work??

Discussion in 'C Programming' started by jt, Mar 3, 2008.

  1. jt

    jt Guest

    everytime we pass different number of variables.
    even though there is no polymorphism concept in C.
    hw do they accomplish.
     
    jt, Mar 3, 2008
    #1
    1. Advertising

  2. jt

    santosh Guest

    jt wrote:

    > everytime we pass different number of variables.
    > even though there is no polymorphism concept in C.
    > hw do they accomplish.


    The format string specifies everything that they need to know (and
    expect) of the following arguments. In C, functions with variadic
    arguments can accept differing number and type of arguments though they
    must accept at least one fixed parameter. This is a somewhat advanced
    topic in C. You don't need to worry about their actual mechanics until
    much later.
     
    santosh, Mar 3, 2008
    #2
    1. Advertising

  3. jt wrote:
    >
    > everytime we pass different number of variables.
    > even though there is no polymorphism concept in C.
    > hw do they accomplish.


    "Variadic functions", aka "varargs". The functions are defined as
    taking an unspecified list of parameters of unspecified types.

    For example:

    int printf(const char * restrict format, ...);

    --
    +-------------------------+--------------------+-----------------------+
    | Kenneth J. Brody | www.hvcomputer.com | #include |
    | kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h> |
    +-------------------------+--------------------+-----------------------+
    Don't e-mail me at: <mailto:>
     
    Kenneth Brody, Mar 3, 2008
    #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. code_wrong

    Re: printf scanf problem

    code_wrong, Aug 2, 2003, in forum: C Programming
    Replies:
    1
    Views:
    417
    /dev/null
    Aug 2, 2003
  2. Dan Pop

    Re: printf scanf problem

    Dan Pop, Aug 4, 2003, in forum: C Programming
    Replies:
    0
    Views:
    647
    Dan Pop
    Aug 4, 2003
  3. =?ISO-8859-1?Q?Martin_J=F8rgensen?=

    scanf (yes/no) - doesn't work + deprecation errors scanf, fopen etc.

    =?ISO-8859-1?Q?Martin_J=F8rgensen?=, Feb 16, 2006, in forum: C Programming
    Replies:
    185
    Views:
    3,402
    those who know me have no need of my name
    Apr 3, 2006
  4. =?ISO-8859-1?Q?Martin_J=F8rgensen?=

    difference between scanf("%i") and scanf("%d") ??? perhaps bug inVS2005?

    =?ISO-8859-1?Q?Martin_J=F8rgensen?=, Apr 26, 2006, in forum: C Programming
    Replies:
    18
    Views:
    681
    Richard Bos
    May 2, 2006
  5. Meske Moday

    Weird usage of printf/scanf? Why do they work?

    Meske Moday, Sep 7, 2009, in forum: C Programming
    Replies:
    15
    Views:
    942
    Old Wolf
    Sep 8, 2009
Loading...

Share This Page