Thread: Variable number of arguments in function.

  1. #1
    Wymiatacz
    Join Date
    Jan 2007
    Location
    Far away
    Posts
    6

    Cool Variable number of arguments in function.

    How to start with my own formating function? I never wrote any with variable number of arguments. How to do it?

    In my case declaration looks like that:
    Code:
    int dprintf(char *str, const char *format, ...)
    But what next, how to handle 1st 2nd or 5th argument??? I would be grateful for printf() function body also.
    Better is an enemy of good ...

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,794
    search va_start on the forum and inet

    http://c-faq.com/varargs/varargs1.html
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
    Last Post: 12-05-2007, 07:18 AM
  2. Change this program so it uses function??
    By stormfront in forum C Programming
    Replies: 8
    Last Post: 11-01-2005, 08:55 AM
  3. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. qt help
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 04-20-2002, 09:51 AM