【发布时间】:2021-12-14 21:37:01
【问题描述】:
嗨,我正在开发这个程序,它计算矩阵的各种计算(例如行列式和跟踪等),我想在结构中使用数组来创建矩阵。
在我的计算.h 头文件中,我有这个:
struct matrices {
int matrix[3][3]; };
在我的计算.c 实现文件中,我有这个函数,它基本上在从用户获取整数输入后创建矩阵:
struct matrices creation (int x, int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8 ) {
struct matrices mmm = {{x, x1, x2}, {x3, x4, x5}, {x6, x7, x8}};
return mmm;
}
但是,我收到错误消息error: extra brace group at end of initializer 定向到struct matrices mmm = {{x, x1, x2}, {x3, x4, x5}, {x6, x7, x8}}; 行
谢谢:)
【问题讨论】:
-
您的意思是使用
struct matrices mmm吗? -
什么 sj95126 说,你的代码中没有称为矩阵的结构。
-
是的,抱歉,我出于某种原因更改了我的代码,但忘记将其移过来。问题不在于名称差异@sj95126
标签: c multidimensional-array struct initialization