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

2nd Array Question

The Quiz Asks: 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".

I thought the right way to code this would be:

char letters [2] {0, 1]; letters = 'alpha';

But that's not right. What am I doing wrong?

3 Answers

James Carney
James Carney
16,255 Points

Letters is an array, you want 'alpha' to be assigned to the first element of the array.

letters = 'alpha'

is the problem there. Also might want to fix the closed bracket at the end of your array to make it a curly bracket. Hope this helps

Stone Preston
Stone Preston
42,016 Points

Declare an array of type 'char' called "letters" with a size of 2. all you have to do is declare it, not populate it so to declare an array with a specific size:

dataType arrayName[4]; 

in that case I gave it a size of 4

Assign the variable "alpha" as the first element of the array "letters". to assign a variable to an element of an array:

arrayName[1] = variableName;

in that case I assigned variableName to the second element in the array

Thanks for the help guys, actually it was entirely my fault but in a totally different way. I deleted my answers from Question 1, and because of that the answer kept coming up as wrong.

James Carney
James Carney
16,255 Points

happens to the best of us