My code:
#include "stdio.h"
main() {
char a,b;
a=getchar();
b=getchar();
putchar(a);
putchar('\n');
putchar(b);
}
getchar() requires user to enter a character and then press enter to assign it to the variable. I expected the program letting me enter the character twice, each time finished by pressing enter. But I was only able to enter one character string and the program will automatically read the first two characters and assign them to each variable. What's the problem?