finding length of string/int?

how can i compare a values length and if it's a certain length, then return, for example how do i do something below in c++?

1
2
3
int number = 15;
if (length_function_here(number) == 3)
return;


length_function_here being the function that can count the length of an int value
If by "count the length" you mean find out the number of digits a number is composed of, then you can use base-10 logarithm:

1
2
3
4
#include <cmath>

...
int totalDigits = log10(number) + 1;
Topic archived. No new replies allowed.