Find the length of a long?

Is there any way to find the length of along? I'm sort of making a library type of program, and the program allows the user to search by a ten digit ISBN. I'm trying to have some error checking to make sure the user doesn't enter more or less than 10 digits, and I'm not sure how to go about checking the length of the input. Any help would be greatly appreciated!
Get the input into a string first, validate it, then if it is OK you can put it into a long.
1
2
3
4
5
6
7
8
9
10
11
unsigned long long get_isbn()
{
    constexpr long long MIN = 999999999 ; // largest 9 digit number
    constexpr long long MAX = 10000000000 ; // smallest 11 digit number
    long long value ;
    std::cout << "isbn (exactly 10 digits)? " ;
    if( std::cin >> value && value > MIN && value < MAX ) return value ;
    std::cin.clear() ;
    std::cin.ignore( 1024, '\n' ) ;
    return get_isbn() ;
}
Topic archived. No new replies allowed.