如何在单个数组中创建多个成员

How to create multiple members in a single array

我会询问用户矩阵的数量,然后为每个矩阵随机分配一个 5x5 矩阵。我可以在单个结构中执行此操作吗?如果是这样那我应该怎么给它分配内存呢,我试过这样做但是没有用。

struct Temp
{
    int *mat[5][5];

}test;

int main(void)
{
    

    int x;

    printf("Enter the number of matrixes : ");
    scanf("%d", &x);

    test.mat= malloc( x* sizeof *test.mat);
    if (test.mat== NULL) {
        fprintf(stderr, "Malloc failed.\n");
        exit(1);
    }
int *mat[5][5];

int* 的 5x5 数组。

要创建指向 int 的 5x5 数组的指针,应该是

int (*mat)[5][5];