No Arguments

This is a discussion on No Arguments within the C Programming forums, part of the General Programming Boards category; how is foo(void) different from foo() ?...

  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 06: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, 02:17 AM
  2. GradeInfo
    By kirksson in forum C Programming
    Replies: 23
    Last Post: 07-16-2008, 04:27 PM
  3. command line arguments
    By vurentjie in forum C Programming
    Replies: 3
    Last Post: 06-22-2008, 07:46 AM
  4. NULL arguments in a shell program
    By gregulator in forum C Programming
    Replies: 4
    Last Post: 04-15-2004, 11:48 AM
  5. registry, services & command line arguments.. ?
    By BrianK in forum Windows Programming
    Replies: 3
    Last Post: 03-04-2003, 02:11 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21