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])应该也行
相关阅读
zenefits valuation 4.5 billion了求统计工作H1B pending, OPT还没过期,应该怎么换工作今年2个同学H1B adv pp,全部没中狗家 题 讨论微软 Bing Ads team 面经问一下现在去UAP大概可以赚多少招聘:cs,ee,applied math @New Jersy从几个法案看 共和党和民主党对华人职业移民的态度 (转载)请问,骑驴找马的时候,怎样才能不让现在公司知道自己在找工作?我在国内金鸡湖散步时求助,有没有人知道德国和瑞士的google咋面试的?LendingClub和Visa的Contractor Openingonsite一家公司可以自己顺道去看另一家公司吗?在公司找工作,被老板发现了,下面会怎么发展?至转行同学: 免费课程邀请你来上, 6/17开始, 限前10名 (转载 (转载)H1b ext REFH1B 中了还能签B1/B2 吗?HR Generalist H1B transfer 被 RFE, specialty occupation报 BlackRock Data Science offer 求意见