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

wilsonkwan
wilsonkwan
3,174 Points

Need help for Challenge array_length 3of3

Challenge 3of3: Print the length of the array real_numbers using the sizeof() function. Your output should look like the following: Array real_numbers can store x items.

Failed to pass this challenge as my code below. Any pointer?

float real_numbers [] = {11.11, 22.22, 33.33, 44.44, 55.55};

printf("Array real_numbers can store %ld items\n", sizeof(real_numbers)/sizeof(float));

Thank you

1 Answer

Hi Wilson,

What kind of error message are you getting?

Did you leave the previous printf statement in place? For task 3 you want to add to the code that you've already written.

It's possible too that it's not liking the \n Try replacing with a period or just taking it out.

sizeof(real_numbers) / sizeof(float) would be the correct way to get the number of items so I think the problem is elsewhere.

wilsonkwan
wilsonkwan
3,174 Points

Hi Jason, Thank you for the hint! The problem was I didn't leave the printf statement from previous task. ;)