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 Objective-C Basics (Retired) Pointers and Memory Array Size and Length

Caleb Kleveter
MOD
Caleb Kleveter
Treehouse Moderator 37,862 Points

What are they telling me in this warning?

I'm on stage 2 of this code challenge and I'm supposed to:

Using the printf function print the size in bytes of the variable real_numbers. your output should look like the fallowing: Array real_numbers is x bytes.

I put in:

printf("real_numbers %ld bytes\n", sizeof(real_numbers));

but a bummer message pops up that says:

That was not the correct string. do you have the correct for mat character? sizeof(real_numbers) returns a long. That format character is %ld.

what does this mean and what should I do about it?

4 Answers

Stone Preston
Stone Preston
42,016 Points

the challenge states: your output should look like the fallowing: Array real_numbers is x bytes.

your printf statement looks like this:

printf("real_numbers %ld bytes\n", sizeof(real_numbers));

which means your output is going to look like this:

real numbers x bytes

where x is going to be the size of real_numbers.

so the error basically says "real numbers x bytes" is not "Array real_numbers is x bytes"

you need to change the string in your print f statement:

printf("Array real_numbers is %ld bytes\n", sizeof(real_numbers));
Caleb Kleveter
MOD
Caleb Kleveter
Treehouse Moderator 37,862 Points

I tried that and it didn't work.Does it have to do with the 1st part of the challenge? Here is what that code looks like:

float real_numbers[] = {1, 2, 3, 4, 5 };

Stone Preston
Stone Preston
42,016 Points

i just tried it and it worked fine. make sure you keep the task 1 code there as well

float real_numbers[] = {1, 2, 3, 4, 5 };
printf("Array real_numbers is %ld bytes\n", sizeof(real_numbers));