1. ## count numbers input

Can anyone tell me about how can i check the number of digits which a user has just put in
for example
input: 21212
number of digits = 5

thanks

2. Depends how there stored.

Assuming they're in a string, you can use strlen(), or if you want to validate that they are actually 5 numbers (as opposed to 4+ 1 letter), you'll have to try something like

- looping through the array, checking each one with isdigit()
- convert to a numeric variable via atoi() or atol() and check the return code to make sure it worked.

I'm sure there's a few other ways too.

3. you could also use -->

Code:
```if(num>=0 && num<=9)
digits=1;
if(num>=10 && num<=99)
digits=2;
if(num>=100 && num<=999)
digits=3;
//so on..```

4. Usually it's easiest to place the number in an array and count the valid elements, but if you want to count the digits of a number without converting it to an array you can make a copy and break it down, counting each digit:
Code:
```/* get input and make a copy */
for ( x = 0; copy != 0; x++ )
copy /= 10;
printf ( "%d contains %d digits\n", input, x );```
-Prelude

5. If you want to get complicated/fancy and you are only talking about integer input (no floating point stuff), you can use logarithms to do this:
Code:
```#include <cmath>
#include <iostream>

using namespace std;

int main()
{
int iValue = 99999;
cout << "Number of digits for " << iValue << " is "
<< floor(log10( iValue )+1.0) << endl;
}```
Outputs 5, change iValue to 100000 for example and it outputs 6. Change it to whatever you want and see how it behaves. Like I said, the caveat is that this only works for integers.

6. Crap... sorry about that, I thought I was on the C++ board. Anyway, my response still applies:
Code:
```#include <math.h>
#include <stdio.h>

int main()
{
int iValue = 99999;
printf( "Number of digits for %d is %d\n", iValue,
(int) floor(log10( iValue )+1.0) );
return 0;
}```