Thread: void funct_name(void) and void funct_name(). Are they same.

  1. #1
    Registered User
    Join Date
    Jun 2011
    Posts
    2

    void funct_name(void) and void funct_name(). Are they same.

    void funct_name(void)
    and
    void funct_name()

  2. #2
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    They are not the same. The first one takes NO arguments while the second one may take an unknown number of arguments. This is mostly a leftover from early C (C89).
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    It depends where those lines fall. Function prototypes are different than function definitions on how they handle empty parenthesis. A function prototype with an empty parameter list means it takes any number of arguments. A function definition with an empty parameter list means is the same as void.

    When in doubt, be specific.


    Quzah.
    Last edited by quzah; 06-11-2011 at 03:19 PM.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 12
    Last Post: 03-27-2009, 02:36 PM
  2. Passing a variable in void to another void function
    By stevedawg85 in forum C++ Programming
    Replies: 5
    Last Post: 05-05-2006, 06:17 PM
  3. Invalid conversion from 'const void*' to 'void*' error
    By prawntoast in forum C Programming
    Replies: 3
    Last Post: 05-01-2005, 10:30 AM
  4. What is this mean? static void *name (void *data)
    By beyonddc in forum C++ Programming
    Replies: 14
    Last Post: 05-05-2004, 03:06 PM
  5. int memCopy(void* , void*, int size)
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 11-19-2001, 03:02 PM

Tags for this Thread