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

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