Arrangement ticket by reference in a procedure

0

My question is this:

I have to do a procedure with two fixes as parameters, one for value and another for reference. My question is that when I compile it gives me an error that says "arr" and "arr2" was not declared in this scope .

I leave this much more basic code:

void Prueba(int arr[],int arr2[]) {
    if (arr[1]==3) arr2[1]=3;
        else arr2[1]=8;
}

The point is that when I leave it like this the procedure works fine, but if I put the "&"; next to arr2 to indicate that it is a passage by reference, throws me that error.

Why is this happening?

    
asked by Martín Larrosa Zugarramurdi 25.03.2018 в 00:10
source

1 answer

0

The declaration of the parameters of the function is correct. ALWAYS arrays are references because they are pointers.

You can declare it like this:

int arr[]

or so:

int *arr

but never with &, that's only for invocation of the function.

    
answered by 25.03.2018 / 01:34
source