有时我看到函数定义如下:
read_dir(dir)
char *dir;
{
DIR * dirp;
struct dirent *d;
/* open directory */
dirp = opendir(dir);
......... so on
这里声明的重要性是什么
char *dir;
在函数名后立即声明指针然后启动函数体的意图是什么。
最佳答案
这是一种较旧的 C 语法,称为“K&R C”,因为它在 legendary book 的原始版本中就是这样出现的.
以前是这样写的:
foo(a, b)
int a;
int b;
{
}
现在
int foo(int a, int b)
{
}
关于c - 为什么参数类型声明在括号外?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2607332/