#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    2
    Rep Power
    0

    Indefinite number of arguments


    How can I get a function with indefinite number of arguments?

    for exemple:

    Code:
    int printf ( const char * format, ... );
    How do I do "..." in a function?

    I'm sorry for the English mistakes, I'm brazilian...
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,392
    Rep Power
    1871
    http://en.wikipedia.org/wiki/Stdarg.h

    Comments on this post

    • eramit2010 agrees
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    2
    Rep Power
    0
    thanks a lot, I have never heard about it...
  6. #4
  7. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,112
    Rep Power
    1803
    Also: http://en.cppreference.com/w/cpp/utility/variadic

    Comments on this post

    • eramit2010 agrees
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    5
    Rep Power
    0
    I think that:


    const char * format - variable format

    . . . - variable name..


    Example:

    char a;

    printf("%s",a);


    I don't know if I helped you

    Comments on this post

    • dwise1_aol disagrees : Read the links that others have supplied.

IMN logo majestic logo threadwatch logo seochat tools logo