[英]Function on a variable declaration
I'm reading the C Programming Language (chapter 5), and I'm confused by this example: 我正在阅读C编程语言(第5章),我对此示例感到困惑:
int n, array[SIZE], getint(int *);
Why is this function call in here like that? 为什么这个函数在这里调用? Is this just some tricky example and invalid code? 这只是一些棘手的例子和无效的代码吗?
It's not calling the function; 它没有调用函数; it's declaring its prototype. 它正在宣布它的原型。 It's equivalent to: 它相当于:
int n;
int array[SIZE];
int getint(int*);
Since the statement began with a type specifier, namely int, then it suggests declaration. 由于语句以类型说明符(即int)开头,因此它建议声明。 Thus what follows is a bunch of comma separated list of identifiers. 因此,下面是一串逗号分隔的标识符列表。
n
being a single int variable. n
是单个int变量。
array
being an array of int. array
是int的数组。
getint
being a function that returns an int and has one parameter that is an int pointer. getint
是一个返回int的函数,有一个参数是一个int指针。 It is unnamed and that is not important because this is a function declaration/prototype. 它是未命名的,并不重要,因为这是一个函数声明/原型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.