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


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

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)