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

Basic C code won't compile in Treehouse

Program runs and complies as it should in Xcode and returns the correct value although it won't accept it. Please help, thanks

float real_numbers[] = {1.1, 2.2, 3.3, 4.4, 5.5}; printf("float %ld bytes\n", sizeof(float)); printf("Array real_numbers is %ld bytes\n", sizeof(real_numbers)); printf("Array real_numbers can store %ld itmes\n", sizeof(real_numbers)/sizeof(float));

4 Answers

Hey Lincoln,

Your first printf statement isn't asked for in the challenge so I don't know if that will throw it off. You're using \n in your strings instead of a period which could be causing it not to pass.

Also, check your spelling on the last printf statement.

Here is my problem again:

Code Challenge: 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 Solution:

float real_numbers[] = {1.1, 2.2, 3.3, 4.4, 5.5}; printf("Array real_numbers is %ld bytes.", sizeof(real_numbers)); printf("Array real_numbers can store %ld times.", sizeof(real_numbers)/sizeof(float));

works in Xcode only, Thank you

I didn't recheck the code challenge again but I think the end of the string was items and not times

Thank you for the quick response and catching those mistakes but that didn't fix it. I am just moving on, as long as it works in Xcode without any problems it would seem to me that it is ok to just move on. Your thoughts?

I would recommend that you complete the challenges Even if earning the points and badges aren't important to you it's still a learning experience. I know sometimes it may seem like you're jumping through hoops just to satisfy the code checker but I think you'll be a better programmer if you stick with it and figure out what it requires.

I think you'll find that a lot of times in programming things need to be an exact way. So I think it's good practice to read the instructions carefully and make sure that you are providing exactly what is required.

I see your logic... thank you for your help and input. That was the problem, I was using times and not items.