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 trialLuke Dunning
231 PointsArray Variables
Hi, i am having trouble understanding why this is incorrect , and i have tried it multiple ways in xcode and it compiles perfectly to what the question is asking, can anyone see an issue with my code ?
include <stdio.h>
int main() {
char alpha[] = {'a'};
alpha[0] = 'a';
printf("alpha %c\n", alpha[0]);
char bravo[] = {'b'};
alpha[0] = 'b';
printf("bravo %c\n", bravo[0]);
return 0;
}
2 Answers
Taylor Weeks
4,009 PointsYou do not need the square brackets in the variable declaration. A character is not an array.
char alpha = 'a'; char bravo = 'b';
Luke Dunning
231 PointsAhh thank you so much Taylor :)