simple scanf() problem

Dear Experts-
Here is my very simple code where I am trying to input each lettre of user's name and then finally display the name:-

void main()
{
char a, b, c;
clrscr();

printf("Entre the first letter: ");
scanf("%c", &a);
printf("\n Entre the sec letter: ");
scanf("%c", &b);
printf("\n Entre the third letter: ");
scanf("%c", &c);

printf("\n Name: %c%c%c", a,b ,c);

getch();

}

// so when this prog. is executed then it asks for first lettre [first printf statement is executed.]
// Then after entering the first lettre rather than just asking for the second letter it directly displays the second and third printf() statements.[two printf() statements are being displayed simulteniously, without getting any input]
// Rather it should display the second printf() first then after getting the second input it should display the third printf() statement.
//
// Help please.
scanf() read two characters instead of one, the input character and the return/enter/'\n'
use getchar() instead

ref: http://www.gidnetwork.com/b-60.html and http://www.cplusplus.com/reference/clibrary/cstdio/getchar/
Topic archived. No new replies allowed.