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

John Dyer
PLUS
John Dyer
Courses Plus Student 761 Points

Challenge task 2 of 3 error

Howdy...I am entering printf("real_numbers is %ld bytes.", sizeof(real_numbers)); for this challenge but I keep getting an error. Keeps complaining about the format character.

4 Answers

Gregory Serfaty
Gregory Serfaty
37,140 Points

is your array is like this float real_numbers[5]; ?

Calvin Nix
Calvin Nix
43,828 Points

Hey John,

There is no need for the parenthesis around real_numbers.

You simply need a space between sizeof and real_numbers.

i.e sizeof real_numbers

John Dyer
PLUS
John Dyer
Pro Student 761 Points

Calvin,

Your suggestion works fine in Xcode :

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

Not in the challenge though.....keep getting the following error:

Bummer! Make sure you are calling printf and passing a string (not an NSString) and "real_numbers" as the parameters. The correct format option is '%ld'.

Not too fussed, just wanted to report it to see if it was something that needs fixing in the challenge itself.

Thanks for your help.

Calvin Nix
Calvin Nix
43,828 Points

Hey John,

I just tested the code challenge and I passed it using the following code.

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

It is possible that the \n is messing it up.

Edit: Plus, your formatting is not correct. You need to also include the word 'Array' and the beginning of your string. Code challenges are very picky :)