Reading a single character in C
scanf("%c",&in);
leaves a newline which is consumed in the next iteration.
Change it to:
scanf(" %c",&in); // Notice the whitespace in the format string
which tells scanf to ignore whitespaces.
OR
scanf(" %c",&in);
getchar(); // To consume the newline
To read just one char, use getchar instead:
int c = getchar();
if (c != EOF)
printf("%c\n", c);
in scanf("%c",&in);
you could add a newline character \n
after %c
in order to absorb the extra characters
scanf("%c\n",&in);