cin >> n;
As the above code, I have declarced an interger variables n.
I try to input the value of n by cin. However, when I try to input a chracter as the input prompt. An error occur. The value of n is not changed.
I know that I can detect the invalid input using the cin.good().... I also try to use the cin.ignore() to delete the invalid character input from istream but fail to do this. Then how can I do to flush the istram so that the character from istream?