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


Help me solve this

6 Answers

Hi 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));

11,940 Points

Please 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?

float real_numbers[5];

Thanks 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");

Got 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));


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

You 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)