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

Print function is giving me an error "size of" for array length

float real_numbers[] = {1,2,3,4,5}; printf("float %ld bytes\n" , size of (float));

it gives me an error that "size" is not declared. I don't understand. I took notes and that's how I was taught.

2 Answers

Hi Renee,

You have a few errors with your code. sizeof shouldn't have a space in it.

Also, it's asking for the size of real_numbers not the size of a float. real_numbers is an array with enough space for 5 floats. So really what they're asking is what's the size of 5 floats.

One more thing is that your output string wouldn't match what it's asking for.

The output string should be in the form Array real_numbers is x bytes.

Your current output string looks like float x bytes\n

Let us know if you're still stuck.

Forgot to mention too that you don't have to initialize your array with 5 values. You only have to declare an array that will hold 5 values.

Putting in 5 numbers still passes but this will work too:

float real_numbers[5];

Thank you Jason for your insight. I did have a space between size of, so I corrected it to "sizeof" and it worked. The little things make a big difference when writing a code!

I appreciate your assistance! I'm new to Treehouse, so I apologize for not responding to your answer.