Arrays in C++ can be treated as pointers to the location of the first element of an array. A two dimensional array can be thought of as an array of pointers, and each of the pointers points to another array. While this isn't strictly speaking how arrays are implemented, C supports implicit conversion between arrays and pointers to the first element, and you can think of them as the same. Array[index] is just syntactical sugar for *(Array + index*sizeof(whatever's in the array))
. So for your function to work, you can just do:
void fn(int (*a)[10]) {
cout<<a[0][0]<<" "<<a[0][1];
}
int main() {
int A[10][10];
A[0][0]=1;
A[0][1]=2;
fn(A);
}
No need to get the address of the array first, because it's already a pointer. However, because you're using C++, you really should consider using standard containers:
void fn(vector< vector<int> > const&a) {
cout<<a[0][0]<<" "<<a[0][1];
}
int main() {
vector< vector<int> > A( 10, vector<int>(10) );
A[0][0]=1;
A[0][1]=2;
fn(A);
}