🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

ridiculous ptr problem

Started by
0 comments, last by AlexM 24 years, 6 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.
Advertisement
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