I have a number like this: int num = 36729; and I want to get the number of digits that compose the number (in this case 5 digits).
int num = 36729;
How can I do this?>
Inefficient, but strangely elegant...
#include #include int main(void) { // code to get value char str[50]; sprintf(str, "%d", value); printf("The %d has %d digits.\n", value, strlen(str)); return 0; }