在C中,当我在函数体之前声明函数签名后面的变量时,它意味着什么?

Kev*_*ang 1 c syntax compiler-errors function method-signature

可能重复:
为什么声明放在func()和{}之间?

在C中,当我在函数体之前声明函数签名后面的变量时,它意味着什么?

例:

int foo (i) int i {
    printf ("the value of variable 'i' is: %d", i);
    return i;
}
Run Code Online (Sandbox Code Playgroud)

当我编译代码以及初始化变量i时,我得到一个编译错误:"无法初始化参数:p"

Evi*_*ach 5

这意味着您正在查看旧代码.这是旧的K&R语法.
基本上它说,是参数,它是一个int

你可以把它重写为

int foo (int i) 
{
    printf ("the value of variable 'i' is: %d", i);
    return i;
}
Run Code Online (Sandbox Code Playgroud)