I am trying to pass a 2D-array to a function using double pointer,however the compiler is giving the following error
[Error] cannot convert 'int (*)[3]' to 'int**' for argument '1' to 'void print1(int**, int, int)
Here is the code:
#include<iostream>
using namespace std;
void print1(int **arr,int r,int c);
int main()
{
int a[2][3]={{10,20,30},{40,50,60}};
int r=2;
int c=3;
print1(a,r,c);
}
void print1(int **arr,int r,int c){
int i,j;
for(i=0;i<r;i++){
for(j=0;j<c;j++){
cout<<arr[i*r+j]<<"\t";
}
}
}
I want to emulate two dimensional array using double pointer.