Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Mansion

arrays and pointers

This topic is 6523 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

if i have 2d array[20][20] and if i malloc 20*20 and put pointer to the begining then i use like x+y*20 to get my data, but what if there is 3d array[3][20][20] and i put pointer to the begining, how can i get to for example 2, 0, 0 with the pointer? is there some formula...?

Share this post


Link to post
Share on other sites
Advertisement
Then you access it like: x+y*20+z*20*20. Naturally if you do access to array[3][20][20] directly like array[z][y][x], compiler does this for you.

Cheers, Altair


"Only two things are infinite, the universe and human stupidity, and I''m not sure about the former." - Albert Einstein

Share this post


Link to post
Share on other sites

  • 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!