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. Advertisements

  2. Jordan Abel

    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. Advertisements

  3. Richard Bos

    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. Advertisements

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. sean
    Replies:
    1
    Views:
    748
    Cowboy \(Gregory A. Beamer\)
    Oct 20, 2003
  2. Philippe Guglielmetti
    Replies:
    3
    Views:
    544
    Victor Bazarov
    Oct 22, 2003
  3. greg
    Replies:
    15
    Views:
    735
    Greg Ewing
    Sep 10, 2004
  4. =?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:
    13,848
    alainsan
    Aug 12, 2011
  5. Hal Vaughan
    Replies:
    2
    Views:
    431
    James Kanze
    Mar 14, 2008
  6. secheese
    Replies:
    5
    Views:
    157
    secheese
    Jul 15, 2003
  7. stu7

    proto-type sub needs new ribbon ?

    stu7, Aug 21, 2003, in forum: Perl Misc
    Replies:
    1
    Views:
    186
    Brian Harnish
    Aug 22, 2003
  8. nopohack

    Net::Ping - problems with syn proto

    nopohack, Feb 17, 2008, in forum: Perl Misc
    Replies:
    1
    Views:
    209
    Ben Morrow
    Feb 17, 2008
Loading...