Thread: How C function can have variable number of parameters?

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    3

    How C function can have variable number of parameters?

    I read how this could be done before. But I could not
    remember where.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Search your reference for stdarg.h.
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Jul 2004
    Posts
    3

    Thanks. This helps. How come most C books

    doesn't mention this?

  4. #4

  5. #5
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >How come most C books doesn't mention this?
    You have been reading the wrong books. Beginner books gloss over topics of an advanced nature, and this is one of those topics. Of course, functions with a variable number of arguments aren't nearly as useful as some would lead you to believe, so they are left out of many texts for that reason as well.
    My best code is written with the delete key.

  6. #6
    Registered User
    Join Date
    Jul 2004
    Posts
    3
    I went through more than a few books for this question before.

    I never need it in practice. Only met it in interview.

  7. #7

  8. #8
    ---
    Join Date
    May 2004
    Posts
    1,379
    couldnt you just use NULL as a parameter you dont need?

  9. #9
    Quote Originally Posted by sand_man
    couldnt you just use NULL as a parameter you dont need?
    NULL will only work with pointers parameters.
    Emmanuel Delahaye

    "C is a sharp tool"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. doubt in c parser coding
    By akshara.sinha in forum C Programming
    Replies: 4
    Last Post: 12-23-2007, 01:49 PM
  3. Variable number of arguments in function.
    By kamoda_pawel in forum C Programming
    Replies: 1
    Last Post: 01-18-2007, 07:18 AM
  4. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  5. A function accepting a variable number of arguments.
    By Lithorien in forum C++ Programming
    Replies: 3
    Last Post: 10-10-2004, 01:48 AM