1. 平时进行函数声明的时候,无参数的函数应该声明成f(void)
C99 P119:
10 The special case of an unnamed parameter of type void as the only item in the list
specifies that the function has no parameters
----------------------------------------------
16: The declaration
int f(void), *fip(), (*pfi)();
declares a function f with no parameters returning an int, a function fip with no parameter specification
returning a pointer to an int, and a pointer pfi to a function with no parameter specification returning an
int.
-----------------------------------------------
不写void是K&R C标准中的, 但是现在,在任何一本书中都推荐使用void的写法
C99: 6.7.5.3
Empty parameter lists
C distinguishes between a function declared with an empty parameter list and
a function declared with a parameter list consisting of only void.
The former is an unprototyped function taking an unspecified number of arguments,
while the latter is a prototyped function taking no arguments.
// C code
extern int foo(); // Unspecified parameters
extern int bar(void); // No parameters
void baz()
{
foo(0); // Valid C, invalid C++
foo(1, 2); // Valid C, invalid C++
bar(); // Okay in both C and C++
bar(1); // Error in both C and C++
}
2. K&R C标准,还可以在函数外定义函数输入参数
void fun(i)
int i;