Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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: