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

Array Size and Length Challenge 3 of 3

So I looked around the forums and I still don't see what I am doing wrong.

The challenge is:

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.

And my answer was:

float real_numbers [5];
printf("Array real_numbers is %ld bytes\n", sizeof real_numbers);
printf("Array real_numbers can store %ld items.\n", sizeof real_numbers);

Now, I know that 3rd line is not right, but I'm confused on what is needed here. Just hints if you can, I'd like to figure this one out on my own.

3 Answers

To get the number of items stored in the array you'll need to perform some basic math. If you need more of a hint let me know, and good luck.

Okay so I thought about this all day and I'm going to have to ask for another hint please.

You need to use the size of a float to calculate the count of the array. If you're still stuck the last minute or so of the video has the answer.

Ah, yes of course, thank you!