Code
#include <iostream>
void display(int, int, void* );
int main()
{
int A[][2]= { 0, 2,
4, 2,
2, 2};
int m=3, n=2;
display(m, n, &A[0][0]);
}
void display(int m, int n, void *p)
{
int (*q)[m][n]=( int(*)[m][n] )p; // This causing error
for(int i=0; i<=m-1; i++)
{
for(int j=0; j<=n-1; j++)
{
std::cout<<q[i][j]<<" ";
}
std::cout<<"\n";
}
}
Output(Error)
Cannot initialize a variable of type 'int (*)[m][n]' with
an rvalue of type 'int (*)[m][n]'
https://stackoverflow.com/a/35657313/11862989 here user mention this but it's not working.
int (*q)[m][n]=( int(*)[m][n] )p;
so why this typecasting is not happening.