Proto Question

Discussion in 'C Programming' started by ian, Nov 6, 2006.

  1. ian

    ian Guest

    Hi;

    What is

    void daily_log(char *, ...);

    saying, the 3 periods?

    Regards
    Ian
    ian, Nov 6, 2006
    #1
    1. Advertising

  2. ian

    Jordan Abel Guest

    2006-11-06 <>,
    ian wrote:
    > Hi;
    >
    > What is
    >
    > void daily_log(char *, ...);
    >
    > saying, the 3 periods?


    It means it can take different amounts of arguments. Like printf.

    Read the documentation of your daily_log function for details.
    Jordan Abel, Nov 6, 2006
    #2
    1. Advertising

  3. ian

    Richard Bos Guest

    "ian" <> wrote:

    > What is
    >
    > void daily_log(char *, ...);
    >
    > saying, the 3 periods?


    This really should be in your textbook. It's a prototype for a function
    with a variable number of arguments (also known as a variadic function).
    When it's called, it must have at least one argument that is a char *,
    and any number of extra arguments. If you call it, that's all you need
    to know, really; it functions just like, e.g., printf(). One other
    thing: you must have a prototype in scope when you call a variadic
    function, and you can't rely on automatic type conversion in the
    variable arguments.
    If you want to write a function like this yourself, you use the
    functionality provided by <stdarg.h> to do so. Note that there's no way
    to find out how many arguments were passed in any call; you must find
    that out from the arguments themselves, e.g. from information present in
    the non-variable arguments (as in printf()), or from a special marker
    argument (e.g., the last argument could always be a null pointer).

    Richard
    Richard Bos, Nov 6, 2006
    #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. Philippe Guglielmetti
    Replies:
    3
    Views:
    383
    Victor Bazarov
    Oct 22, 2003
  2. greg
    Replies:
    15
    Views:
    547
    Greg Ewing
    Sep 10, 2004
  3. =?ISO-8859-2?Q?Przemys=B3aw_Staniszewski?=

    Ethernet and TCP/IP proto in vhdl

    =?ISO-8859-2?Q?Przemys=B3aw_Staniszewski?=, Sep 29, 2006, in forum: VHDL
    Replies:
    8
    Views:
    12,625
    alainsan
    Aug 12, 2011
  4. Hal Vaughan
    Replies:
    2
    Views:
    325
    James Kanze
    Mar 14, 2008
  5. secheese
    Replies:
    5
    Views:
    106
    secheese
    Jul 15, 2003
Loading...

Share This Page