gpt4 book ai didi

c - 如何从函数返回矩阵,在 c 中?

转载 作者:太空宇宙 更新时间:2023-11-04 08:14:42 25 4
gpt4 key购买 nike

<分区>

我的矩阵加法的c代码如下:

mat(int n,int a[][5],b[][5] ){
int i,c[5][5];

for(i=0;i<5;i++){
for(j=0;j<5;j++)
c[i][j]=a[i][j]+b[i][j];

return c;
}

当我编译这个时,我的编译器发现了错误:

||warning: command line option '-Wzero-as-null-pointer-constant' is valid for C++/ObjC++ but not for C [enabled by default]|
C:\Users\Amir Khasru\Desktop\retuturn_a_matrix.c|2|warning: return type defaults to 'int' [-Wreturn-type]|
C:\Users\Amir Khasru\Desktop\retuturn_a_matrix.c|2|warning: no previous declaration for 'mat' [-Wmissing-declarations]|
C:\Users\Amir Khasru\Desktop\retuturn_a_matrix.c||In function 'mat':|
C:\Users\Amir Khasru\Desktop\retuturn_a_matrix.c|8|error: return makes integer from pointer without a cast|
||=== Build failed: 1 error(s), 3 warning(s) (0 minute(s), 0 second(s)) ===|

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com