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) Fundamentals of C Arrays

Not sure how to do challenge

Challenge task 2:

"Declare an array of type 'char' called "letters" with a size of 2. Assign the variable "alpha" as the first element of the array "letters"."

char alpha; alpha = 'a';

char letters[2]; letters[0] = 'a';

2 Answers

Stone Preston
Stone Preston
42,016 Points

you are almost right. It states "Assign the variable "alpha" as the first element of the array "letters".""

you have

letters[0] = 'a';

which assigns 'a' to the first element of letters, but what you need to do is assign the variable alpha to the first element of the array letters

letters[0] = alpha;

I tried that, but it does not work.

I originally wrote the following code but it did not work either:

char letters[2];
letters[0] = alpha;
Stone Preston
Stone Preston
42,016 Points

are you sure? I just tried the challenge and got it to work. Here is my complete code:

char alpha = 'a';

char bravo = 'b';

char letters[2];

letters[0] = alpha;

I got it. Thanks for all your help!