Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Objective-C Basics (Retired) Beyond the Basics Arrays

Memory Address units?

Is this video correct? Since an int is say 2 bytes, then shouldn't the memory addresses for a 3 element int array be like 1000, 1002, and 1004? I guess I'm assuming the memory address is in units of bytes. Regardless of the specific units, this video seems to suggest that the memory address range of an array of 3 ints would be the same as an array of 3 doubles.

1 Answer

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

The example was simplistic to depict subscripting to access individual elements in an array. Each memory address does not represent bytes allocated. I didn't want to get into memory allocators because that is a lot more complicated. There are several algorithms on how memory is allocated which varies based on architecture and operating system.