Hi. I have this part of code.
int main() {
int **table = NULL;
allocated_matrix(table, 3, 3);
//next instructions
}
void allocate_matrix((what_type_here)table, int rows, int columns) {
table = (int **) malloc(rows * sizeof(int *));
for (int i = 0; i < rows; i++) {
table[i] = (int *) malloc(columns * sizeof(int));
}
}
I want to allocate a matrix in another function(which is allocate_matrix). The thing is the matrix is allocated inside allocate_matrix function, but when it goes back to main() the table variable still has a NULL value, but it should have an address value. I tried this with the type int** instead of (what_type_here). I'm not sure how to do it so it works properly.
Thanks in advance.