Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef READ_NUMBER_HPP_
- #define READ_NUMBER_HPP_
- #include <string>
- #include <iostream>
- #include <limits>
- template <typename T>
- void readNumber(std::wstring err_msg, T & number)
- {
- while(true)
- {
- while(!(std::wcin >> number))
- {
- std::wcout << number << std::endl;
- std::wcout << err_msg << std::endl;
- std::wcin.clear();
- std::wcin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
- }
- if(number > 0)
- {
- std::wcin.clear();
- std::wcin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
- break;
- }
- std::wcout << err_msg << std::endl;
- }
- }
- #endif //READ_NUMBER_HPP_
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement