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.
Do not understand what the error message means. It tells me I have the correct string but not the correct format.
Isn't %s the correct formatting for a string? When I do this in Xcode it compiles and gives me "Array real_numbers is 20 bytes." Why does the Treehouse console say it is wrong? And what would be correct?
float real_numbers; printf("Array %s is %ld bytes.\n", "real_numbers", sizeof(real_numbers));
I feel like the message that the challenge is giving you is confusing. The issue isn't that %s is the wrong formatter - that is the correct one to use with a string - it is that the string within the quotes is not formatted as TH expects it to be...that's confusing, I know, so here you go:
When you check your work TH sees this - literally:
"Array %s is %ld bytes."
When what it is expecting - literally is:
"Array real_numbers is %ld bytes."
If you replace your %s with "real_numbers" and remove "real_numbers" as the second argument you're sending to printf, your code will pass - as such:
float real_numbers; printf("Array real_numbers is %ld bytes.", sizeof(real_numbers));
I'm not sure if it is a bug or just a poorly 'formatted' question and response. I hope this helps you out.