Use fgets
to read a whole line into a buffer. If you only want to process the first character, you can just ignore the rest. Something along the lines of:
char buf[MAX_LINE_LEN];
if (fgets(buf, MAX_LINE_LEN, stdin))
{
char a = buf[0];
/* Do handling... */
}
else
{
/* error */
}
Coded in browser, may contain traces of error.