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 trialmikema
1,678 PointsUsing the printf function print the size in bytes of the variable real_numbers. Your output should look like the followi
here is my code, i dont see any thing wrong with it but it just keep telling me that's incorrect...
float real_numbers[5]; printf ("Array real_numbers is ld% bytes.\n",sizeof(real_numbers));
3 Answers
Stone Preston
42,016 Pointsprintf ("Array real_numbers is ld% bytes.\n",sizeof(real_numbers));
your format specifier is incorrect. Its %ld
not ld%
Dustin Mote
3,590 Pointsprintf("Array real_numbers is %ld bytes\n", sizeof(real_numbers)*sizeof(float)); is still not working for me
Edwin Rivera
924 PointsFuture advice to anyone, I over thought the answer when it was just asking for the float array and the printf statement with the sizeof(real_numbers) only.
Good luck :D
mikema
1,678 Pointsmikema
1,678 Pointsthanks a lot...didn't notice that...may i ask one more question, why %ld?when do we use %ld
Stone Preston
42,016 PointsStone Preston
42,016 PointsMike Ma the sizeof() function returns a long integer. since it returns a long integer you need to use the format specifier for long integer which is %ld