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.

Jonathan Guerrero
Front End Web Development Techdegree Graduate 18,245 Pointshttp://teamtreehouse.com/library/objectivec-basics/pointers-and-memory/array-size-and-length
Help me solve this
6 Answers

Jason Anello
Courses Plus Student 94,597 PointsHi Jonathan,
You have the correct output string and format specifier. The only problem is that printf
is expecting a second argument so that it can take that value and place it where you have the %ld
It's asking you to print the size of the array. You want to use the sizeof operator
printf ("Array real_numbers is %ld bytes.", sizeof(real_numbers));

lordcozycat
11,940 PointsPlease elaborate on your issue. It wouldn't be good for your learning if we simply handed you the answers :) Which task are you having troubles with?

rishavatreya
4,945 Pointsfloat real_numbers[5];

Jonathan Guerrero
Front End Web Development Techdegree Graduate 18,245 PointsThanks for your answers. I'm trying to solve task 2 Here is my code:
float real_numbers[] = {1.1, 1.2, 1.3, 1.4, 1.5}; printf("Array real_numbers is %ld bytes");

Jonathan Guerrero
Front End Web Development Techdegree Graduate 18,245 PointsGot it. Thanks for your help. Here is the final code for task 2. float real_numbers[5]; printf("Array real_numbers is %ld bytes", sizeof(real_numbers));

Jonathan Guerrero
Front End Web Development Techdegree Graduate 18,245 Pointsthanks,
I'm trying to solve task 3 now Here is my code: <p> float real_numbers[5]; printf("Array real_numbers is %ld bytes", sizeof(real_numbers)); printf("Array real_numbers can store %ld items", sizeof(real_numbers)); </p> what's wrong with my code

Jason Anello
Courses Plus Student 94,597 PointsYou want to divide the total size of the array by the size of a float to get the number of items.
sizeof(real_numbers) / sizeof(float)