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

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
Courses Plus 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 :)