Why the following c++ code keeps output “bad data, try again”?

后端 未结 6 1981
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-14 21:34
int main()
{
        int temp;
        while (cin>>temp, !cin.eof())
        {
                if (cin.bad())
                {
                        throw r         


        
6条回答
  •  星月不相逢
    2021-01-14 22:16

    Because x is not an integer, the operator>> operator doesn't read anything, so when you clear the bit and try again, the same thing results.

提交回复
热议问题