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) Pointers and Memory Array Size and Length

Andy Monk
Andy Monk
279 Points

It seems task 2 and 3 have the answers the wrong way around. Task 2 requires a byte length, and task 3 an item length..

Task 2 is asking for a byte length of the float array (so length of a float multiplied by the array size), but it accepts only the array length, whereas task 3 is asking for an array length, but accepts the byte size.

Or am I missing something?!

obey me
obey me
1,135 Points

so what is your problem the code problem or the question ?? ..

2 Answers

I think you have confused some thing. In task 2 it asks for the size of real_numbers in bytes. Using the function "sizeof()" returns the value of its input in bytes. In the 3rd task though, it asks for the length of the array using sizeof(). Because the array has float values, each float value is usually 4 or 8 bytes (by default) according to if you are on a 32 bit or a 64 bit system. So, if you want to find the length of float you have to divide the number of bytes with the number of bytes equivalent to a float. So it asks for "sizeof(real_numbers)/sizeof(float)".

Andy Monk
Andy Monk
279 Points

Yep, you're right. It appears I was on a different planet when I submitted my question. Many thanks Gloria: