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

array length

why doesn't this work?:

float real_numbers [5] = {11.1,22.2,33.3,44.4,55.5}; printf("array real_numbers %ld bytes", sizeof (real_numbers));

2 Answers

Michael Hulet
Michael Hulet
47,911 Points

I bet it's because you're using curly braces instead of square brackets to declare your array. Try this:

float real_numbers [5] = [11.1,22.2,33.3,44.4,55.5]; 
printf("array real_numbers %ld bytes", sizeof(real_numbers));

That didn't do the trick. Here is the assignment.

Using the printf function print the size in bytes of the variable real_numbers. Your output should look like the following: Array real_numbers is x bytes.

Hi Stephen,

Your output isn't exactly matching what the challenge wants.

You need to capitalize Array and you're missing is from your output.

Also, you don't have to fill the array with 5 floats. float real_numbers[5]; is enough. You only need to declare space for 5 floats.