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 - Code Challenge Arrays

For some reason I can not understand what question #4 is looking for here. This is what I have for the question: Print the results. Your output should look like "letters a b".

char alpha;
alpha = 'a';
char bravo;
bravo = 'b';

char letters[ ] = {a, b};

printf("letters %c %c", letters[0], letters[1]);

It keeps giving me an error saying to remember the correct format character for char is %c

Any ideas what I am doing wrong?

3 Answers

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

Your code is mostly right. Except you need to assign the variables alpha and bravo when creating the letters array. Not sure where you are getting a and b from.

I did have that line as: char letter[2] = {alpha, bravo};

however that does not work either. So I decided to sue another format all together and go with the letters [ ] and call out the a and the b. Still can not get it to work either way I do. It just calls out that %c is the correct format. Any other ideas?

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

char letters[2] = {alpha, bravo}; should work. I just tried it. You had letters misspelled.

I did put in exactly how you have it and keep having this """Bummer! Make sure you're creating variables of type 'char' and setting them to the correct values."""

Yea I had a typo in the forum post however I did not in the online test portal. It is working now, not sure why or how it got fixed but it took my code as I had it and says its good now. Anyways thanks for all your help Amit, I really appreciate it. Great course so far!!