Hi all!
I need to find a way of calculating the number of digits in an integer, here's a glimpse of what I've got so far:
Code:
if ( ( userdigit / 1 ) < 1 )
{
cout << "1 digit integer!";
}
else if ( ( userdigit / 10 ) < 1 )
{
cout << "2 digit integer!";
}
else if ( ( userdigit / 100 ) < 1 )
{
cout << "3 digit integer!";
}
else if ( ( userdigit / 1000 ) < 1 )
{
cout << "4 digit integer!";
}
else if ( ( userdigit / 10000 ) < 1 )
{
cout << "5 digit integer!";
}
... And variants of, none of which have been any success!
Does anybody have a good way of doing this?