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

Embarrassingly, I can't figure out this question: "Declare 2 separate variables of type char named "alpha" and "bravo". Assign the letter 'a' to the variable "alpha" and the letter 'b' to "bravo"."

Here is the code I wrote:

char letters[a, b] = {"alpha", "bravo"};

I have also tried a bunch of other things. I tried a similar method used in the float example in the video that preceded this code challenge, but I think there is a difference between the two that I missed.

8 Answers

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

Oh, I finally get it! The code is not getting replaced, it is building on top of itself. Thanks again!

Should look like this...

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

Thanks :)

Okay, the printf code is a little easier once you figure out the formatting for it.

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

(use /n to create a new line in your own code)

When I had the line break \n in my code, I was getting an error, but it was fine in Xcode. Anyway, thanks for posting the help.

No problem, let me know if you figure out the "Print the results" section!

Okay, I can't figure out section 2 now :P I keep re-watching the video, but I have no clue what I am missing. All this code works just fine in Xcode.

Here is my section 2 or 4 code challenge code:

char letters[1] = {"alpha", "bravo"};

Let me know if you figure out the printf code...

I got it, thankfully.

That's where I am lost is on the printf step.. Help! Haha

Gracias!

You're welcome!