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

Xcode 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

try 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

thank you! that was the issue :)

awesome. glad you got it working

Thank you! that was it :)