<climits> should have macros for INT_MAX and INT_MAX, as well as ranges for other types.
Code:
#include <iostream>
#include <climits>
int main()
{
std::cout << "Max int = " << INT_MAX << std::endl;
std::cout << "Min int = " << INT_MIN << std::endl;
std::cin.get();
}
As for checking user input, one thing is clear, you can't take the input as int, because you can't put more in it than it can hold. You should take it as a string and then in you can validate in any way you want.
If you just want to check if user input was valid, you can use something like that. (Note that it can't tell exactly what the exact problem with the input was.)
Code:
#include <iostream>
int main()
{
int num = 0;
std::cout << "Enter an integer: ";
if (!(std::cin >> num)) {
std::cout << "Invalid input" << std::endl;
std::cin.clear();
}
else
std::cout << "Ok: " << num << std::endl;
std::cin.ignore();
std::cin.get();
}