How can I nest variadic functions?

Discussion in 'C Programming' started by Boltar, Sep 17, 2007.

  1. Boltar

    Boltar Guest

    Hi

    Is it possible to next variadic functions. Eg if I wish to do
    something like this...

    void mainfunc(char *fmt, ...)
    {
     
    Boltar, Sep 17, 2007
    #1
    1. Advertising

  2. Boltar <> writes:
    > Is it possible to next variadic functions. Eg if I wish to do
    > something like this...
    >
    > void mainfunc(char *fmt, ...)
    > {


    Looks like you hit Send before you finished writing your article.

    Function definitions cannot be nested, whether they're variadic or
    not. You can *declare* a function inside a function definition:

    void foo(void) /* definition of foo */
    {
    void bar(void); /* delaration of bar */
    /* ... */
    }

    but there's rarely a good reason to do so and 'bar' has to be defined
    somewhere else anyway.

    See question 20.24 in the comp.lang.c FAQ, <http://www.c-faq.com/>.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, Sep 17, 2007
    #2
    1. Advertising

  3. Keith Thompson <> writes:
    > Boltar <> writes:
    >> Is it possible to next variadic functions. Eg if I wish to do
    >> something like this...
    >>
    >> void mainfunc(char *fmt, ...)
    >> {

    >
    > Looks like you hit Send before you finished writing your article.
    >
    > Function definitions cannot be nested, whether they're variadic or
    > not. You can *declare* a function inside a function definition:
    >
    > void foo(void) /* definition of foo */
    > {
    > void bar(void); /* delaration of bar */
    > /* ... */
    > }
    >
    > but there's rarely a good reason to do so and 'bar' has to be defined
    > somewhere else anyway.
    >
    > See question 20.24 in the comp.lang.c FAQ, <http://www.c-faq.com/>.


    And I see from your other posting that I completely misunderstood what
    you were asking.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, Sep 17, 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. Loony

    variadic functions

    Loony, Sep 12, 2003, in forum: C++
    Replies:
    2
    Views:
    366
    Kevin Goodsell
    Sep 12, 2003
  2. Colin Walters
    Replies:
    2
    Views:
    527
    Ben Pfaff
    Feb 13, 2004
  3. Ross A. Finlayson
    Replies:
    19
    Views:
    605
    Keith Thompson
    Mar 10, 2005
  4. Replies:
    2
    Views:
    353
    Dave Thompson
    Feb 27, 2006
  5. Replies:
    5
    Views:
    368
Loading...

Share This Page