Q:

why std::cin doesn't give error on "char"

Here is a small code:
char a;
while(std::cin >> a) {
    std::cout << a << " is pressed\n";
}

When I type in "w", i get "w is pressed".
When I type in "www", i get "w is pressed" 3 times in a row.
Can someone please explain why this happens?
Thanks

A:

When you use std::cin to read a char variable it reads one character at a time. That is why you get 3 iterations in the while loop for input www. 

