[英]Segmentation fault
In C, when I try to run this program, I get a "Segmentation fault". 在C中,当我尝试运行该程序时,出现“段错误”。 What does it mean?
这是什么意思? How can I fix this?
我怎样才能解决这个问题?
Tag tagNewDataPoint(const double x[MAX_DIMENSION],
const double w[MAX_DIMENSION],
const int d)
{
int separator_arr,point_arr;
double result = 0;
for (separator_arr=0;separator_arr<d;separator_arr++)
{
for (point_arr=0;point_arr<d;separator_arr++)
{
result += w[separator_arr]*x[point_arr];
}
}
if (result <0)
{
return NEG;
}
else if (result >0)
{
return POS;
}
else
{
return NOTAG;
}
}
This: 这个:
for (point_arr=0;point_arr<d;separator_arr++)
should be: 应该:
for (point_arr=0;point_arr<d;point_arr++)
You increment the separator_arr
, but checks the pointer_arr
value (which is never changed) soon enough separator_arr
is too big, and your address is invalid. 您增加了
separator_arr
,但是在足够的separator_arr
太大且地址无效的情况下,立即检查了pointer_arr
值(从未更改)。
You have index crosstalk. 您有索引串扰。
for (point_arr=0;point_arr<d;separator_arr++)
should be 应该
for (point_arr=0;point_arr<d;point_arr++)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.