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

Using the printf function print the size in bytes of the variable real_numbers. Your output should look like the followi

here is my code, i dont see any thing wrong with it but it just keep telling me that's incorrect...

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

3 Answers

Stone Preston
Stone Preston
42,016 Points
printf ("Array real_numbers is ld% bytes.\n",sizeof(real_numbers));

your format specifier is incorrect. Its %ld not ld%

thanks a lot...didn't notice that...may i ask one more question, why %ld?when do we use %ld

Stone Preston
Stone Preston
42,016 Points

Mike Ma the sizeof() function returns a long integer. since it returns a long integer you need to use the format specifier for long integer which is %ld

Dustin Mote
Dustin Mote
3,590 Points

printf("Array real_numbers is %ld bytes\n", sizeof(real_numbers)*sizeof(float)); is still not working for me

Future advice to anyone, I over thought the answer when it was just asking for the float array and the printf statement with the sizeof(real_numbers) only.

Good luck :D