Advertisement

ridiculous ptr problem

Started by January 06, 2000 06:50 PM
0 comments, last by AlexM 24 years, 11 months ago
this is the code, i got it to work, but i don''t understand why i had to add extra twists: int CalculateTriangleNormals(_EGroup*group,_ESegment*seg) { code here accessing seg with seg->vertexcount; } int UpdateTriangleDisplay(_EGroup*group,_ESegment*seg) { CalculateTriangleNormals(group,seg); } int main() //oversimplified { //group and seg ptrs already exist, valid UpdateTriangleDisplay(group,seg); } this gives me an error because when it accesses the seg->vertexcount member it gets 4378165838 or something. however, if i use _EGroup**group in the UpdateTriDisplay function and pass *group to CalcTrinormals, it works, gives me say 2 or 3, as it should. I don''t recall this happening before, so please enlighten me, why? Thanks in advance, Alex.
Well, how are you declaring group and seg?

int main() //oversimplified
{
//group and seg ptrs already exist, valid
UpdateTriangleDisplay(group,seg);
}

If they are pointers, then this looks fine, but if they are static variables, then you need to reference them with the & operator:

int main() //oversimplified
{
//group and seg ptrs already exist, valid
UpdateTriangleDisplay(&group,&seg);
}


Jim

This topic is closed to new replies.

Advertisement