Jump to content
  • Advertisement


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

The way memory is allocated...

This topic is 5217 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 allocate memory as such...
int num1 = new int(1);
int num2 = new int(5);
int num3 = new int(8);
Is this memory guaranteed to be allocated in a row, as in an array? I''m trying to figure out pointer arithmetic and I''m wondering if this is what''s going wrong, or my pointer arithmetic.

Share this post

Link to post
Share on other sites
Different languages, compilers, computers and OS''s will do memory allocations in different ways. The best would be to always assume that you don''t know how it is allocated .

If you want seperate arrays in continuous memory, allocate a single array like SiCrane suggested, and then use either pointers or aliases to access three seperate arrays inside that memory space.


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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!