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

Problem with arrays ( char ).

Hi everybody, I'm not quite sure what the question is asking. 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". Can someone please help me out ? thank you

4 Answers

Kang-Kyu Lee
Kang-Kyu Lee
52,045 Points

This question looks quite straightforward. Maybe did you put quotation mark for values 'a' and 'b'?

Aaron Arkie
Aaron Arkie
5,345 Points

I believe you just have to initialize alpha and bravo as a "char(character)" type. so before you type alpha or bravo, declare what it is by stating it as a char type.

so the formula is type-object = ' ';

char Alpha= 'a'; char bravo= 'b';

*note: use single quotes ' ' not double quotes " " <--- as this is for a string. I hope this helps, good luck!

include <stdio.h>

int main()

{

char variables[ ] = {"alpha","bravo"} ;    
variables[0] = 'a';
variables[1] = 'b';

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

return 0;    

}

I did it in this way and there seems to be no error. But how do I separate the two variables ?

Kang-Kyu Lee
Kang-Kyu Lee
52,045 Points

?

'a' replaces 'alpha' in your code as value. but the task asks a variable named 'alpha' hope it helps!

Okay. Thank you very much kang kyu lee and Aaron Arkie, I figured out how to do it.

here's my code :

char alpha = 'a';

char bravo = 'b';

printf("%c\n",alpha);

printf("%c\n",bravo);
Kang-Kyu Lee
Kang-Kyu Lee
52,045 Points

You're welcome! Let's go for it!