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: Print the Results

I am a total newb to all of this, your help would be greatly appreciated! I can't figure out how to do this, these are the instructions:

Print the results. Your output should look like "letters a b".

This is what I have so far...

char alpha = 'a'; char bravo = 'b';
char letters[2]; letters[0] = alpha; letters[1] = bravo; 

printf(letters a %c\n", 'b';)

2 Answers

In your printf(), you have the semi-colon inside the arguments. It should be after the (), not in between them. You should probably be using %c both times as well, so letters %c %c instead of a %c. After the "", you need to specify where it gets the information from, in this case the variable 'letters', and since you're storing the information in arrays you need to specify which spot it's in. Remember, arrays start at 0. The alpha variable stores a, which is being stored in letters[0], and bravo stores b, which is being held in *letters[1]. I haven't been through this course yet, but hopefully this helps. This is the complete code:

char alpha = 'a'; char bravo = 'b';
char letters[2]; letters[0] = alpha; letters[1] = bravo; 

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

Josh Trommel thank you that solved it! :)