I get this warning when compiling on Dev-C++ 4.9.9.2Code:double readDouble( void ) { double input; while (!(cin >> input)) { cout << "Invalid data.\n"; cin.clear(); cin.ignore(numeric_limits< double >::max(), '\n'); } return input; }
Problem is that if I enter a character or any invalid data it goes into the infinite loop that I am trying to avoid. I have the same loop in a function for integers but no problems there.Code:68 C:\Projects\CISP400\invdata.cpp [Warning] passing `double' for converting 1 of `std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::ignore(std::streamsize, typename _Traits::int_type) [with _CharT = char, _Traits = std::char_traits<char>]'



LinkBack URL
About LinkBacks


