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

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


        
6条回答
  •  伪装坚强ぢ
    2021-01-14 22:19

    If you use formatted input/output the data must match. x is not an integer. Try to enter 5 Enter. Or define temp as std::string.

提交回复
热议问题