how to pass array by reference
Hey guys, I have an array of 3 elements and a function that can take an array of 4 elements, I want to manipulate the 4 elements in the function and pass them mack by reference, hopefully my sample code will enlighten my problem.
Code:
void doubleElements(int *array[3]);
int main(void)
{
int array1[3];
array1[0] = 2;
array1[1] = 4;
array1[2] = 6;
array1[3] = 8;
doubleElements(&array1);
}
void doubleElements(int *array[3])
{
array[0] = array[0]*2;
array[1] = array[1]*2;
array[2] = array[2]*2;
array[3] = array[3]*2;
}
Is there something wrong here??? Obviously I want:
array1[0] = 4
array1[1] = 8
array1[2] = 12
array1[3] = 16
Appreciate the help!