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

Adi Jain
Adi Jain
2,771 Points

What am supposed to do the "x" part is throwing me off.

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.

Jake Adams
Jake Adams
1,608 Points

What code do you have so far? If you share it here, I can help out

1 Answer

Jake Adams
Jake Adams
1,608 Points

You need to replace 'x' with the actual size of the array (in bytes). You will need to use the formatting options available in the printf function call. You can read about that here

printf("Array real_numbers is %ld bytes");

That's the first part. %ld is a placeholder to let C know we are going to put a long, signed integer there (see link above for descriptions of the placeholders).

The second part is to pass printf the value that we want to put in that placeholder. printf takes any number of arguments. The first argument that you see above is the message format. All arguments that follow correspond to any placeholders that we have in the message format.

printf("Array real_numbers is %ld bytes", sizeof(real_numbers));

Hope that helps!

Adi Jain
Adi Jain
2,771 Points

Thank You Jake, sorry for not responding faster I had accidentally divided the size of real numbers by float, so that is what was messing me up.