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

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,843 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.