【发布时间】:2011-02-06 19:18:51
【问题描述】:
我正在开发一个程序,我尝试通过引用传递参数。我正在尝试通过引用传递 2D int 数组和 1D char 数组。
函数原型:
void foo (int* (&a)[2][2], char* (&b)[4])
函数调用:
foo (a, b);
但是,当我在 gcc 上使用 -ansi 和 -Wall 标志编译代码时,出现以下错误:
foo.c: At top level:
error: expected ‘)’ before ‘&’ token
error: expected ‘;’, ‘,’ or ‘)’ before ‘char’
foo.c: In function ‘main’:
error: too many arguments to function ‘foo’
我已经剥离了程序的其余代码,并专注于引发错误的位。我在 StackOverflow 上搜索并尝试了不同的方法来传递参数,但它们似乎都不起作用。 (I took this way of passing parameters from the discussion on StackOverflow here.)
你能告诉我哪里出错了吗?
【问题讨论】:
标签: c arrays pass-by-reference