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
Breanna Walsh
72 PointsStuck on the "Arrays" assignment One.
Hi, i tried declaring the variables alpha and bravo the way i first learned, but it's not working. So, since i'm learning about arrays, i tried two separate array declarations. That didn't work either. Here is the assignment, and my answer. 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". Answer: char alpha[] = {a}; char bravo[] = {b};
My first answer was: char alpha = 'a'; char bravo = 'b';
Hopefully i just forgot some stuff since yesterday.. Thanks,
6 Answers
Stone Preston
42,016 Pointshmmm if you had
char alpha = 'a';
char bravo = 'b';
first I would think that would have worked for the first part of the challenge. Try that again and see if it works
Breanna Walsh
72 PointsHi, yes, after typing my forum post, i pressed check work, and it went through. But now, i'm stuck again.
Here is the challenge: 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". Here is my answer: char letters[1] = {'alpha',};
I hope it works soon. Haha, getting frustrated that i may not be doing so well at programming. :(
Stone Preston
42,016 PointsYou did not declare your array first before modifying it, which would look like
char array[2];
Assigning the value of a variable to another variable usually looks something like this
datatype varName = otherVarName;
Treat the first element of the letters array as the left side, and then you simply have your alpha variable name as the left. Also remember array indexes start at zero, not 1. So to assign the first element of some array of characters the value of some variable would look like this
array[0] = yourVarName;
Breanna Walsh
72 PointsOh, i was using the 1, as the total size of the array, not where i would start! Thanks so much. ^^
Also, to make code blocks on the forum, i use markdown?
Stone Preston
42,016 PointsThere are many ways to markdown your code, but the simplest is to start a new line and then indent your line of code 4 spaces.
Breanna Walsh
72 PointsI finished the assignment. Thanks bunches! :)
Should i follow along in Xcode as I watch, or watch first, and duplicate after? Want to be efficient. xD
Stone Preston
42,016 Pointsi follow along as I watch.
Breanna Walsh
72 PointsOkay, yeah, i've been doing that too, seems to work fine. :) Just need to give my memory some practice, been out of school for years now.
Ivor Houston
206 PointsIvor Houston
206 Pointshi, sorry i have tried that but it still does not work for me! :( please help
Ivor Houston
206 PointsIvor Houston
206 Pointshi, sorry i have tried that but it still does not work for me! :( please help