# Thread: PASSINAG A bidimansional array at a function

1. ## PASSINAG A bidimansional array at a function

how do I pass as referance a bidimansional array ata function?

this
int a[1][2];
void f(int **b);
doesnt work ! type mismatch.

-i found this way ...
struct c
{
int *p[2];
} array;

voit initNewType()
{
array.p[0] = &(a[0][0]);
array.p[1] = &(a[0][1]);
}

void f(c *value)
{ //how do i move the array index thru the bidimansioal array?????
*((*value).p[i]+j); //value at a[j][i]....but there 's a mistake someone can help me?
//there's a simpler solution instead that using this mess?

}
main()
{ f(&array);
}

///there's a esyer way to pass by referance a duble array?

if you emailme to bruno.marovelli@fastwebnet.it i'll really apprciate it!

2. Please don't cross-post. It's considered extremely rude.

3. One solution is a pointer to a 2-dimentional array.

void f(int ***data)
{}

Kuphryn

4. >void f(int ***data)
That's not a pointer to a two dimensional array. It's a pointer to a pointer to a pointer which would likely constitute a pointer to a dynamically simulated two dimensional array. But the question was about arrays, not pointers.

5. If you are going to change the arrays content, then you do not need to pass it by reference
Code:
void f(int arr[4][4]);

int main(){
int myArray[4][4];
f(myArray);
return 0;
}
But if you are going to allocate it dinamically, within the function for example, then you must pass int***.

6. closed