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

Do i have the correct format character?

float real_numbers[5]; printf("real_numbers %ld bytes", sizeof(real_numbers)); printf("float %ld bytes", sizeof(float)); printf("Array real_numbers %ld bytes", sizeof(real_numbers)/ sizeof(float));

I keep being told i dont have the correct format character and treehouse reminds me that i should be using %ld but I am?

array_length.mm
float real_numbers[5];
printf("real_numbers %ld bytes\n", sizeof(real_numbers));
printf("float %ld bytes\n", sizeof(float));
printf("Array real_numbers %ld bytes\n", sizeof(real_numbers)/ sizeof(float));

2 Answers

Hey,

You pretty much have to code down except for some minor things. Just needed the "Array" in front of real_numbers and a "." after bytes on the second and fourth line of code. As far as the 3rd line "printf("float %ld bytes\n", sizeof(float));" you wouldn't need that because that is essentially your second line of code 'printf("Array real_numbers is %ld bytes.", sizeof(real_numbers));'

You have to type everything to the "T" or else the code challenges wont pass you, hope that helps.

float real_numbers[5]; Challenge 1 printf("Array real_numbers is %ld bytes.", sizeof(real_numbers)); Challenge 2 printf("Array real_numbers can store %ld items.", sizeof(real_numbers)/sizeof(float)); Challenge 3