Z*4
3 楼
或者写
int fun(int *p[3])应该也行
int fun(int *p[3])应该也行
j*y
6 楼
如果能写成这样,那么就可以写成int fun(int **p)了。
记得int main(int argc, char *argv[])也可以写成int main(int argc, char **argv)
Chevy提供的是正确的用法。
相似的例子在K&R的书上也有:
If a two-dimensional array is to be passed to a function, the parameter
declaration in the function must include the number of columns; the number
of rows is irrelevant, since what is passed is, as before, a pointer to an
array of rows, where each row is an array of 13 ints. In this particular
case, it is a pointer to objects that are arrays of 13 ints. Thus if the
array daytab is to be passed to a function f, the declaration of f would be:
f(int daytab[2][13]) { ... }
It could also be
f(int daytab[][13]) { ... }
since the number of rows is irrelevant, or it could be
f(int (*daytab)[13]) { ... }
which says that the parameter is a pointer to an array of 13 integers. The
parentheses are necessary since brackets [] have higher precedence than *.
Without parentheses, the declaration
int *daytab[13]
is an array of 13 pointers to integers. More generally, only the first
dimension (subscript) of an array is free; all the others have to be
specified.
【在 Z**********4 的大作中提到】
: 或者写
: int fun(int *p[3])应该也行
相关阅读
恳请大家提供CCC/ICC公司的信息加州湾区公司急招一名software engineer那我就展开说说Epic说说我们这今天挂掉的一个candidate关于phone screen面试How to read this letter火线求救,career fair会被问到behavioral question吗?怎么对付??Facebook sign on 给10w, 是不是疯了啊。。要不要申请opt延期,大家是怎么做的?紧急招人版上有人面过google统计的onsite么? (转载)万能的版,求个室友吧!面完一周了,啥消息也木有,感觉很不妙纠结迷茫的选择,求建议请问面HM的老板的老板要注意什么? (转载)求助,面试的presentation 取什么标题比较好?急,该不该给hiring manager发这封信 。。。在线等export license 和O1 visa application 可以同时办理吗?epic怎么就火了?Epic是health care那个么?