Jump to content
  • Advertisement
Sign in to follow this  
tobiasknight

odd looping error

This topic is 4856 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So i have this weird problem with my loop and some variables. I'm using this to load a set of coords into an array <code> for(loop = 0;loop < totalFrames;loop++) { vertexArray[loop] = malloc((vertexCount * 3) * sizeof(float)); for(loop2 = 0;loop2 < vertexCount * 3;loop2++) { [file scanFloat:&vertexArray[loop][loop2]]; } } </code> that's the code.. totalFrames is set at 8 vertexCount is read from a file and here it is set to 3 from loop 0-6 vertexCount is still 3 during loop 7 it's a random huge number.. just huge like 4559136 this time around. anyone have any idea why?

Share this post


Link to post
Share on other sites
Advertisement
Just a guess - is vertexArray large enough for vertexArray[7] to be a valid index? It looks like you might be writing outside the bounds of the array and changing vertexCount

Share this post


Link to post
Share on other sites
Quote:
Original post by chowe6685
Just a guess - is vertexArray large enough for vertexArray[7] to be a valid index? It looks like you might be writing outside the bounds of the array and changing vertexCount


HAHAH i forgot to change that!
My original test was static, then i threw in some variables to allow for n number of frames to an animation and i didn't update the first part of the array.. checking now =) heh

ahh now just to remember how to do dynamic allocation for multidimensional arrays

heh thanks

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!