错误:无效操作数到二进制+ (拥有浮点'和float **
void clc_moy_mdl(int n, int m,float *mt[3][30])
{
float s;
int i,j;
s=0;
remplire_matrice(n,m,tab,mt);
for(j=1;i<=n;j++)
{
for(i=1;i<=(m-1);i++)
{
s =s+ mt[i][j];
printf("%f",s);
}
mt[i][j]= s /(m);
}
}
这是我编写程序的程序 我在第12行中有错误 错误:无效的操作数到二进制 +(具有“ float”和“ float **”) 我该如何解决?
void clc_moy_mdl(int n, int m,float *mt[3][30])
{
float s;
int i,j;
s=0;
remplire_matrice(n,m,tab,mt);
for(j=1;i<=n;j++)
{
for(i=1;i<=(m-1);i++)
{
s =s+ mt[i][j];
printf("%f",s);
}
mt[i][j]= s /(m);
}
}
this is a procedure from a program that I write it
I have an error in line 12
error:invalid operands to binary + (have 'float' and 'float **')
How can I solve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
参数
mt
被声明为具有数组类型float *[3] [30]
因此,表达式
mt [i] [j]
has类型float *
和在这些语句中,并且
使用指针和浮点数错误地操作。
取而代之的是,要么您必须写入
或
声明该功能,要么
像注意该数组索引从0开始。因此,
您程序中这样的循环似乎可以产生不确定的行为。你应该写
The parameter
mt
is declared as having the array typefloat *[3][30]
Thus the expression
mt[i][j]
has the typefloat *
and in these statementsand
there are used incorrectly operations with a pointer and a float.
Either instead you have to write
and
or to declare the function like
Pay attention to that array indices start from 0. So it seems the for loops like this
in your program can produce undefined behavior. You should write
float *mt [3] [30]
将mt
定义为指针的2D阵列float
。删除
*
您还可以使用传递的大小来声明此参数。
请记住,索引是从
0
开始的,然后使用正确的类型(size_t
)float *mt[3][30]
definesmt
as 2D array of pointers tofloat
.Remove the
*
You can also use the passed sizes to declare this parameter.
Remember that indexes start from
0
and use the correct types for sizes (size_t
)