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

Trouble with an Objective-C print statement third step

the question is:

"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 code below:

  • float real_numbers[5];
  • printf("Array real_numbers can store %ld items.\n", (sizeof(real_numbers) / sizeof(float)));

And it doesn't work...

5 Answers

Hi Sofiane,

Your code for the 3rd step looks good and will pass.

Did you keep your printf statement from task 2 in place? Generally, you want to keep previous code there and add to it.

Hi Jason,

I tried all possible things and it still doesn't work, can you fix that please?

Can you post all the code that you're trying?

In your question, you only posted 2 lines of code but you should have 3 total when trying to pass task 3.

You were supposed to have a printf statement from task 2 which I don't see in your question.

Then you add the printf for task 3 after that one.

What error message are you getting?

  • I include stdio.h in the first line

  • float real_numbers[5];

  • printf("Array real_numbers can store %ld items.\n", (sizeof(real_numbers) / sizeof(float)));

Ok, you don't have to include stdio.h.

Where is the printf from task 2?

What I was trying to say in my answer and comment was that you have to keep previous code. It looks like you have tried to reuse the printf from task 2 in order to complete task 3.

The code you wrote for task 2 still needs to be there.

Can you link to the challenge if you're still having trouble?

Thank you it works lol, it's like you said ! I deleted de printf from the task 2... ;)

Glad you have it sorted out!

tu l'as plieeeeerrr