3 回答

TA貢獻(xiàn)1816條經(jīng)驗(yàn) 獲得超6個(gè)贊
這是參數(shù)列表的舊式語(yǔ)法,它仍然被支持。在K&R C中,您還可以關(guān)閉類型聲明,它們將默認(rèn)為int。E.
main(argc, argv)char *argv[];{ return 0;}

TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超11個(gè)贊
void f(a) float a; { /* ... */}
f
double
float
void f(float a);void f(a) float a; {}
double
float
// option 1void f(double a);void f(a) float a; {}// option 2// this declaration can be put in a header, but is redundant in this case, // since the definition exposes a prototype already if both appear in a // translation unit prior to the call. void f(float a); void f(float a) {}

TA貢獻(xiàn)1844條經(jīng)驗(yàn) 獲得超8個(gè)贊
#include <stdio.h>int foo(c)int c;{ return printf("%d\n", c); }int bar(x)double x;{ return printf("%f\n", x); }int main(void){ foo(42); /* ok */ bar(42); /* oops ... 42 here is an `int`, but `bar()` "expects" a `double` */ return 0;}
$ gcc proto.c $ gcc -Wstrict-prototypes proto.c proto.c:4: warning: function declaration isn’t a prototype proto.c:10: warning: function declaration isn’t a prototype $ ./a.out 42 0.000000
- 3 回答
- 0 關(guān)注
- 523 瀏覽
添加回答
舉報(bào)