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
Sofiane Hasnaoui
2,693 PointsTrouble 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
Jason Anello
Courses Plus Student 94,610 PointsHi 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.
Sofiane Hasnaoui
2,693 PointsHi Jason,
I tried all possible things and it still doesn't work, can you fix that please?
Jason Anello
Courses Plus Student 94,610 PointsCan 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?
Sofiane Hasnaoui
2,693 PointsI 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)));
Jason Anello
Courses Plus Student 94,610 PointsOk, 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?
Sofiane Hasnaoui
2,693 PointsThank you it works lol, it's like you said ! I deleted de printf from the task 2... ;)
Jason Anello
Courses Plus Student 94,610 PointsGlad you have it sorted out!
Dahmani Youcef
Courses Plus Student 30 Pointstu l'as plieeeeerrr