相关疑难解决方法(0)

函数声明与原型的替代(K&R)C语法

这个C语法有什么用- 使用'K&R'样式函数声明?

int func (p, p2)
    void* p;
    int  p2;
{
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我能够在Visual Studios 2010beta中写这个

// yes, the arguments are flipped
void f()
{
    void* v = 0;
    func(5, v);
}
Run Code Online (Sandbox Code Playgroud)

我不明白.这种语法有什么意义?我可以写:

int func (p, p2)
    int  p2;
{
    return 0;
}
// and write
int func (p, p2)
{
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

它似乎唯一指定的是它使用了多少参数和返回类型.我猜没有类型的参数有点酷,但为什么允许它和int paranName函数声明后?有点奇怪.

这还是标准的C吗?

c function kernighan-and-ritchie function-declaration function-definition

69
推荐指数
3
解决办法
1万
查看次数