user200632 user200632 - 6 months ago 38
C++ Question

c++ array access through pointer

A simple question about accessing array information through pointers that I can't seem to figure out. I'm passing a bunch of multi-dimentional arrays into a function. Now they are not dynamic but even if static, I have to pass them as pointers right? (If I'm wrong, please do correct me)

So once I do pass them into a function, how do I access it?

int main()
int anArray[5][5] = // member intializations
void foo(int * anArray) //or should that be int ** anArray ??
cout << anArray[2][2] << endl; // how should i address this..?


If your arrays are of fixed size, you can do it this way:

void foo(int arr[5][5])
    cout << arr[2][2] << endl;