You could convert it to a string and get the length of the string.
You could count how many times it is divisible by ten.
There might be better solutions than these though.
#include <math.h>
unsignedint getLength(int number)
{
unsignedint length = 0;
if (number < 0) //When it is beneat zero is has a - before the number, so that makes the length larger
length++;
number = abs(number); //this is because you need to work with the positive version of it.
for (unsignedchar c = 1; c < 10; c++) //It only goes to 10 since 2^32 is in text 10 symbols long
{
if (number < pow(10, c)) //when you reach a point where it is smaller than pow(10, c) you know the length.
length += c;
//Like, when it is 987 it is smaller than 1000 but not smaller than 100. So you can see that the zeros of the result of pow(10, c) represents the length of the number. c is the number of zeros so c is added to the length.
}
return length;
}