Thread: No Arguments

  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    99

    No Arguments

    how is foo(void) different from foo() ?

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    foo() is unspecified number of arguments, foo(void) is no arguments. In declarations, at least.

  3. #3
    Registered User
    Join Date
    Jun 2007
    Posts
    99
    Quote Originally Posted by robwhit View Post
    foo() is unspecified number of arguments, foo(void) is no arguments. In declarations, at least.
    then how is foo(...) different from foo() ?

  4. #4
    Registered Abuser
    Join Date
    Jun 2006
    Location
    Toronto
    Posts
    591
    If you are referring to C (I will assume so..):
    foo() is a call to the function "foo" with no arguments.
    <type> foo(void) is the proper way to declare/define a function that takes no arguments.
    <type> foo(...) is partly the way to declare/define a function that takes a variable number arguments. Keep in mind though that there must always be at least one argument in a variadic function, so
    <type> foo(<type>, ...) is at least necessary.
    Last edited by @nthony; 06-18-2007 at 05:30 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  2. GradeInfo
    By kirksson in forum C Programming
    Replies: 23
    Last Post: 07-16-2008, 03:27 PM
  3. command line arguments
    By vurentjie in forum C Programming
    Replies: 3
    Last Post: 06-22-2008, 06:46 AM
  4. NULL arguments in a shell program
    By gregulator in forum C Programming
    Replies: 4
    Last Post: 04-15-2004, 10:48 AM
  5. registry, services & command line arguments.. ?
    By BrianK in forum Windows Programming
    Replies: 3
    Last Post: 03-04-2003, 02:11 PM