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
Victoria Cooper
2,111 PointsXcode error
Hi! I am following along with the Pointer Power video and Xcode is giving me errors and not sure why... this is my code (identical to the video, as far as I can tell):
int main() { char *letter;
char c = 'k';
letter = &c;
printf("%c is always the same as %c\n", c, *letter);
char c = 'q';
printf("%c is always the same as %c\n", c, *letter);
char c = 'x';
printf("%c is always the same as %c\n", c, *letter);
return 0;
}
when I ask Xcode to run, I get a "build failed" and a red error message that says "redefinition of 'c'". unsure of how to proceed, any help appreciated! thank you!
2 Answers
Stone Preston
42,016 Pointstry using
char *letter;
char c = 'k';
letter = &c;
printf("%c is always the same as %c\n", c, *letter);
c = 'q';
printf("%c is always the same as %c\n", c, *letter);
c = 'x';
printf("%c is always the same as %c\n", c, *letter);
return 0;
instead. you only need to declare c as a char once, you can just reference it as c after that
Victoria Cooper
2,111 PointsThank you! that was it :)
Victoria Cooper
2,111 PointsVictoria Cooper
2,111 Pointsthank you! that was the issue :)
Stone Preston
42,016 PointsStone Preston
42,016 Pointsawesome. glad you got it working