I am trying to create a Linear Algebra library from scratch in C.
At first, I created a matrix with struct. The dimension and size of the matrix are allocated dynamically.
I want to create such a function so I can copy the data in a 2D array and save it in the matrix.

The code that I have written so far has been shown below:

```
#include <stdio.h>
#include <stdlib.h>

typedef struct matrix {
    int rows, cols;
    int** data;
} matrix;

void initmatrix(matrix* mat) {
    mat->data = (int**) malloc(mat->rows * sizeof(int*));
    for (int i = 0; i < mat->rows; i++) {
        *(mat->data+i) = (int*) malloc(mat->cols * sizeof(int));
    } 
}  

void fillwith_0(matrix* mat) {
    for (int i = 0; i < mat->rows; i++) {
        for (int j = 0; j < mat->cols; j++) {
            *(*(mat->data+i)+j) = 0;
        } 
    } 
} 

void printmatrix(matrix* mat) {
    for (int i = 0; i < mat->rows; i++) {
        for (int j = 0; j < mat->cols; j++) {
            printf("%d", *(*(mat->data+i)+j));
        }
        printf("\n");
    }
}

```

I want to implement a setvalue function that takes two arguments, one is the pointer to the matrix, and the other is a 2D array, so I can copy the data in it inside the matrix.

How would I do so?