So i am trying to create a structure that contains information about a matrix, and trying to initialize that matrix by putting every element 0. I get no errors, but after compiling the program crashes, any help?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
struct board_s {int length; int width; int **m;};
typedef board_s *board;
board newboard(int inputlength, int inputwidth){
board play = new board_s;
play->length = inputlength;
play->width = inputwidth;
//CREATE A MATRIX
int **m = newint*[inputlength];
int i=0;int j;
while (i<inputlength) {
play->m[i]=newint[inputwidth];
j=0; while (j<inputwidth) {play->m[i][j]=0; j++;};
i++;};
return play;
};