Problem
Count the digits of a number (1234 -> 4).
A do-while loop is used so that the number 0 is counted as 1 digit.
int main() {
int num = 1234;
int len = 0;
do{
num = num / 10;
len++;
}while(num != 0);
cout << len; // 4
}
int num = 1234;
int len = to_string(num).length();
cout << len;