Pelles C forum

C language => Beginner questions => Topic started by: Alessio on January 23, 2009, 11:30:41 AM

Title: void as parameter function
Post by: Alessio on January 23, 2009, 11:30:41 AM
Hi,

on a C++ book I've found:

Quote
The meaning of an empty function parameter list in C++ is dramatically different than in C. In C, it means all argument checking is disabled (i.e., the function call can pass any arguments it wants). In C++, it means that the function explicitly takes no arguments. Thus, C programs using this feature might cause compilation errors when compiled in C++.

The function call can pass any arguments it wants ? Sure ?
I've tested it with

Code: [Select]
#include <stdio.h>

int foo(void)
{
return 1;
}

int main(void)
{
foo("1", "3", 2);

return 0;
}

The compiler reports "Too many arguments to 'foo'".

I've misunderstood the book's quote ?
This rule was breaked by C99 standard ?

Thanks.

Title: Re: void as parameter function
Post by: Pelle on January 23, 2009, 06:25:55 PM
You should use func() - not func(void)...