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

Osman Safa Kaya
Osman Safa Kaya
556 Points

array length

printf("Array real_numbers can store %ld items.", sizeof(array)/sizeof(real_numbers));... Can anyone help me with this out? What am i doing wrong? Thanks in advance.

3 Answers

Holger Liesegang
Holger Liesegang
50,595 Points

Welcome to Treehouse, Osman Safa Kaya ,

float real_numbers[5];
printf("Array real_numbers is %ld bytes.\n", sizeof(real_numbers));
printf("Array real_numbers can store %ld items.\n", sizeof(real_numbers)/sizeof(float));

would be the right answer to Challenge task 3 of 3 "Print the length of the array real_numbers using the sizeof() function. Your output should look like the following: Array real_numbers can store x items." because you have to divide the size of your array variable (real_numbers) by the size of one item (in this case a float) it occupies in memory.

There's a great video here in the forum section on the right "Tips for asking questions" that might help you with posting your questions and code on the forum.

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.

It is asking you to print the sizeof real_numbers. Be sure to follow what the question says. Look to what it asks your printf output to be.

Osman Safa Kaya
Osman Safa Kaya
556 Points

Thank you all for your support!