in c: func(void) vs. func() [duplicate]

void means the function does not take any parameters. For example,

int init (void)
{
    return 1;
}

This is not the same as defining

int init ()
{
    return 1;
}

because in the second case the compiler will not check whether the function is really called with no arguments at all; instead, a function call with arbitrary number of arguments will be accepted without any warnings (this is implemented only for the compatibility with the old-style function definition syntax, pre-ANSI).

Leave a Comment