how to return 2d array using pointers [duplicate]

  arrays, c++, function-pointers

I want to know how to fix error in returning array using pointer I have always this error please help me to fix this problem

error: cannot convert ‘char (*)[n]’ to ‘char**’ in return|
.

char **nextstate(char arr[][5], int n)// error line code
{ char next[n][n];
    for (int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {if(emptyorstay(arr,i,j)==true)next[i][j]= '1';
           else next[i][j]= '0';
        }
    }
    return next;

Source: Windows Questions C++

LEAVE A COMMENT