Puzzle

Discussion in 'C Programming' started by Ramanathan, Sep 4, 2004.

  1. Ramanathan

    Ramanathan Guest

    What is the difference between the following declarations?
    void funct();
    void funct(void);
    I guess there is definitely a difference between them.
    Ramanathan, Sep 4, 2004
    #1
    1. Advertising

  2. Ramanathan wrote on 04/09/04 :
    > What is the difference between the following declarations?
    > void funct();


    This is a function declaration. It indicates the name of the function
    and the return type, but nothing about the type and number of
    parameters (unspecified). It's usage is not recommended.

    > void funct(void);


    This is a detached function prototype that indicates the name of the
    function, the return type, and that the function accepts no parameters
    at all.

    --
    Emmanuel
    The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
    The C-library: http://www.dinkumware.com/refxc.html

    "C is a sharp tool"
    Emmanuel Delahaye, Sep 4, 2004
    #2
    1. Advertising

  3. Ramanathan

    Mike Wahler Guest

    "Ramanathan" <> wrote in message
    news:...
    > What is the difference between the following declarations?
    > void funct();


    Declares a function which doesn't return anything,
    does not specify what parameters it has.

    > void funct(void);
    > I guess there is definitely a difference between them.


    Declares a function which doesn't return anything,
    specifies that it has no parameters.

    Aside: In C++ the two are equivalent.

    -Mike
    Mike Wahler, Sep 4, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Earl Teigrob
    Replies:
    3
    Views:
    6,646
    Nedu N
    Aug 6, 2003
  2. dwa

    Design Puzzle!

    dwa, Jun 10, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    365
    Cowboy \(Gregory A. Beamer\) [MVP]
    Jun 10, 2004
  3. Shankara Narayanan

    Booking puzzle....

    Shankara Narayanan, Jun 17, 2004, in forum: ASP .Net
    Replies:
    20
    Views:
    923
    bredal Jensen
    Jun 30, 2004
  4. VB Programmer
    Replies:
    2
    Views:
    429
    Alan Lambert
    Nov 4, 2004
  5. G. Stewart

    regex puzzle!

    G. Stewart, Nov 23, 2004, in forum: ASP .Net
    Replies:
    8
    Views:
    508
    G. Stewart
    Nov 25, 2004
Loading...

Share This Page