I have this following code.
#include <stdio.h>
int main () {
char letter1;
char letter2;
printf("Enter Letter 1: ");
letter1 = getchar();
printf("\n");
printf("Enter Letter 2: ");
letter2 = getchar();
printf("\n");
printf("%c - %c\n", letter1, letter2);
return(0);
}
I am trying to use getchar()
to define letter1
and letter2
, however it will only work for letter1
, then set the value of letter2
to '\n'
. Does anyone know a work around for this, so I can type values for both variables?