Consider the following code:
#include<stdio.h>
void main()
{
    int p = 0;
    char a = 0;
    while(p == 0)
    {
        p = scanf("%[abc]c",&a);
    }
    printf("%c",a);
}
I know if you enter a character except 'a', 'b', or 'c', value of the getting character from input would not be set into the variable a. 
The problem is if you enter a value except the specified characters, the above loop never and never terminates. Apparently, after getting a not specified character in scanf, it will not get any character in the following loop iteration. Where is the origin of this problem?
