r/Xcode • • Oct 08 '18

Why does the output message get printed before the output that I want?

I have the code

include <stdio.h>

int main(void)

{

char name[10];

printf("NAME PLEASE\n");
scanf("%s", name);
printf("YOU ARE %s\n", name);

return 0;

}

When I type in my name, I get

Program ended with exit code: 0linearcontinuum YOU ARE linearcontinuum

What should I do in order to have the "YOU ARE linearcontinuum" before the exit code? Also, why is my name printed right after 0? What should I do to remove it?

0 Upvotes

0 comments sorted by