Tuesday 4 April 2017

c++ - Unable to pass two dimensional array using double pointer as function argument

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
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 for(j=0;j cout< }

}
}


I want to emulate two dimensional array using double pointer.

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...