avatar
j*t
1
已经一天了,真的要疯掉了.好象是个很小的问题,可就是通不过.
double ent,dd;
Node* pHashList;
pCurSV=....; //此处略去
pHashList=pCurSV->hashList;
maxNodes=pCurSV->maxNodes;
for (i=0;i{
ent=pHashList[i]->value; //value is a double
dd=ent+1;
printf("outcom =%f\n",i)
}
每次到i=5后,就出错.Segmentation Fault.
去掉dd=ent+1那一行, 则顺利通过.
真是奇怪极了.
OS is SunOS 5.7 Generic_106541-08 sun4u sparc SUNW,Ultra-60
可能和浮点运算有关.哪位大侠指点一下?
avatar
G*T
2
not sure ur problem. but ..

what is pHashList[i]?
the ith hash list's point?
what's the definition of object pHashList?
I think the problem maybe here.

【在 j**t 的大作中提到】
: 已经一天了,真的要疯掉了.好象是个很小的问题,可就是通不过.
: double ent,dd;
: Node* pHashList;
: pCurSV=....; //此处略去
: pHashList=pCurSV->hashList;
: maxNodes=pCurSV->maxNodes;
: for (i=0;i: {
: ent=pHashList[i]->value; //value is a double
: dd=ent+1;

avatar
w*r
3
it does not mean anything wrong with "dd=ent+1" here.
the segmentation error may occur before that line, most
likely your pointer
manipulations. you'd better to make sure your array does
not go out of bounds, no invalid objects in that array, or
even something already went wrong in codes other than this
piece!
use jdb or xxjdb to monitor the memeory behaviors.
segmentation faults do drive people crazy.

【在 j**t 的大作中提到】
: 已经一天了,真的要疯掉了.好象是个很小的问题,可就是通不过.
: double ent,dd;
: Node* pHashList;
: pCurSV=....; //此处略去
: pHashList=pCurSV->hashList;
: maxNodes=pCurSV->maxNodes;
: for (i=0;i: {
: ent=pHashList[i]->value; //value is a double
: dd=ent+1;

avatar
o*a
4
the pHashList[i] looks weird !
can you make sure Nodes are organized as a array ?
it seems more like a link list to me by its name.
so you can't cite with [] unless it's been overloaded.
在 jjtt (行者) 的大作中提到: 】
avatar
s*s
5
I guess it is the type of i is int while printf try to
acces a float type, whihc casue the access violaion.
so try to change printf("outcom=%d\n",i);
just guess.

【在 o**a 的大作中提到】
: the pHashList[i] looks weird !
: can you make sure Nodes are organized as a array ?
: it seems more like a link list to me by its name.
: so you can't cite with [] unless it's been overloaded.
: 在 jjtt (行者) 的大作中提到: 】

avatar
t*n
6
Ding!
I think this is the right answer.

【在 s******s 的大作中提到】
: I guess it is the type of i is int while printf try to
: acces a float type, whihc casue the access violaion.
: so try to change printf("outcom=%d\n",i);
: just guess.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。