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 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: 或者写
: int fun(int *p[3])应该也行
相关阅读
大过年被雷,晴天霹雳,求建议faculty面试工业界职位,如何比较好地回答这个问题? (转载)惊天霹雳,刚刚被裁问个职业规划的问题[合集] H4 pending, 可以拿到h1b receipt就工作吗?Release Engineer NeededKnowledgeable in new and emerging technologies,JD这个要读要面试公司的paper发现一个公式有点错误,说还是不说?Capital One怎么样?绿卡政策如何?谢谢谢谢谢!intern得多不受欢迎啊Opening Position for Graphic Designer一个startup的CEO跟我说不选他们,我会后悔的。。。我们公司招人intern面经加求建议常说的A家是amazon还是apple有没有不经过OPT从F1直接H1B的?有没有人找到work at home工作的?intern一般几个月A家 first phone interview请问何时要求opt加急