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:
... And variants of, none of which have been any success!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!"; }
Does anybody have a good way of doing this?



LinkBack URL
About LinkBacks


