Hi,
you're right. I think it would be good to clear with a little function
the keyboard-buffer to prevent that the next call of 'scanf'
takes the signs who are in the keyboard-buffer after the last
call of 'scanf':
Code:
#include <stdio.h>
void clearKeyboardBuffer(void)
{
while (getc(stdin) != '\n')
;
}
int main(int argc, char **argv)
{
char letter[5];
int i;
printf("Enter the Name of letter \n");
for (i = 0; i < 5; i++)
{
printf("Enter letter %d: ", i);
scanf("%c", &letter[i]);
clearKeyboardBuffer();
}
for (i = 0; i < 5; i++)
{
printf("Nr:%d %c\n", i, letter[i]);
}
return 0;
}