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 trialTurd Furgeson
2,579 PointsArray 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.
3 Answers
Alex Kolody
13,748 PointsI 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
42,016 Pointsit 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
2,579 PointsThanks, 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.
Stone Preston
42,016 PointsStone Preston
42,016 Pointscan you post a link the challenge please