I am struggling with function int** Solve(). I did not find solution anywhere, or maybe I can not express my problem accuratelly. I am unable return right value, I always get compilator error or segmentation fault. How to initialize int ptr**, which I want to return from function? Note that function type (int**) is given, and I am not able to change it. I tried to use calloc, because if I wanted to return something line int ptr[4][4], it said I am returning local variable. I don't know what to do, and ptr does not have to be int** maybe. I just want to return right elements and using return ptr. My code:
int** Solve(){
int array[6][6];
//some determining of array's elements...
int **ptr=calloc(4,sizeof(int*));
for(int i=0;i<4;i++){
for(int j=0;j<4;j++){
ptr[i][j]=array[i+1][j+1];
}
}
return ptr;
}