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 Arrays, Length, and Size

Turd Furgeson
Turd Furgeson
2,579 Points

Array Challenge part 3 problems

Question: Print the length of the array real_numbers using the sizeof() function. Your output should look like the following: Array real_numbers can store x items.

My reply:

float real_numbers [5] = {}; printf("Array real_numbers is %ld bytes./n", sizeof(real_numbers)/sizeof(float));

This is racking my brain. Any clues as to what I'm doing wrong at this point? Thanks in advance.

Stone Preston
Stone Preston
42,016 Points

can you post a link the challenge please

3 Answers

Alex Kolody
Alex Kolody
13,748 Points

I had the same issue with this one, but finally figured it out. It checks to make sure task 2 works as well as task 3. So your code should look like this,

float real_numbers [5] = {}; 
printf("Array real_numbers is %ld bytes./n", sizeof(real_numbers));
printf("Array real_numbers can store %ld items./n", sizeof(real_numbers)/sizeof(float));
Stone Preston
Stone Preston
42,016 Points

it could be the fact that you initialized it as an empty array. maybe try just declaring it like so:

float real_numbers[5];

or it could be your string. Make sure your string is EXACTLY as asked for in the challenge. does the challenge want a period on the end?

Turd Furgeson
Turd Furgeson
2,579 Points

Thanks, gentlemen. Looks like it was still looking for the the second print statement along with the question asked (as Alex pointed out). Guess I wasn't expecting to carry over the second statement. Ooops.