Errors/warnings passing int/char arrays by reference
Posted
by Ankur Banerjee
on Stack Overflow
See other posts from Stack Overflow
or by Ankur Banerjee
Published on 2010-04-11T21:11:42Z
Indexed on
2010/04/11
21:13 UTC
Read the original article
Hit count: 355
I'm working on a program where I try to pass parameters by reference. I'm trying to pass a 2D int array and a 1D char array by reference.
Function prototype:
void foo (int* (&a)[2][2], char* (&b)[4])
Function call:
foo (a, b);
However, when I compile the code with -ansi
and -Wall
flags on gcc, I get the following errors:
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’
I've stripped out the rest of the code of my program and concentrated on the bits which throw up the errors. I've searched around on StackOverflow and tried out different ways to pass the parameters, but none of them seem to work. (I took this way of passing parameters from the discussion on StackOverflow here.)
Could you please tell me where I'm going wrong?
© Stack Overflow or respective owner