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.

Eileen Zimmerman
3,047 PointsObjective-C Basics Code Challenge: Array Length
I cannot seem to pass step 2 of this challenge despite having run the code successfully in XCode.
The challenge says: "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."
This is the code I wrote: float real_numbers[5]; printf("array real_numbers is %ld bytes\n", sizeof(real_numbers)/sizeof(float));
I get this error from Treehouse: Bummer! Make sure you are calling printf and passing a string (not an NSString) and "real_numbers" as the parameters. The correct format option is '%ld'.
In Xcode the console correctly returns: array real_numbers is 5 bytes
What am I doing wrong here? Thanks for your help in advance.
2 Answers

Eileen Zimmerman
3,047 PointsWow, I feel like I just got an email from a celebrity! Thanks for the response Amit. Guess I tried to overcomplicate the challenge, haha.

Amit Bijlani
Treehouse Guest TeacherYou are almost right except that the challenge is asking only for the size of the real_numbers
array and not the length of the real_numbers
array. 5 is the length of the array and does not say how many bytes it contains. sizeof(real_numbers)
will give you the size of the array in bytes.