我试图分配多维数组unitilized阵列中的结构是这样的:分配多维数组用C
typedef struct TestStruct
{
int matrix[10][10];
} TestStruct;
TestStruct *Init(void)
{
TestStruct *test = malloc(sizeof(TestStruct));
test->matrix = {{1, 2, 3}, {4, 5, 6}};
return test;
}
我得到了一个错误:
test.c:14:17: error: expected expression before '{' token
test->matrix = {{1, 2, 3}, {4, 5, 6}};
什么是用C的最佳方式分配矩阵?
数组不能用C语言来分配它们可以被初始化,但是这仅* *可以在定义中完成。 – alk