Name

isdigit - character classification routines

Library

libc.lib

Synopsis

  #include <ctype.h>
  int isdigit (int c);

Return values

The isdigit function returns non-zero if the character is a digit and zero otherwise.

Detailed description

The isdigit function tests if ’c’ is a decimal digit character. Regardless of locale, this includes the following characters only:

‘‘0’’  ‘‘1’’   ‘‘2’’   ‘‘3’’   ‘‘4’’
‘‘5’’ ‘‘6’’   ‘‘7’’   ‘‘8’’   ‘‘9’’
 


Examples

#include<ctype.h> //isdigit()
#include<stdio.h> //printf()
void test_isdigit()
{
   int arr[]={’8’,0xe1,’5’,’Z’,0xfd};
   int i = 0;
   int size = 5;
   for( i=0; i<size; i++)
   {
     int ret = isdigit(arr[i]); //call to the API with chars in arr[]
     if( (!ret) != 0 )
     {
         printf("\n%c is not a digit", arr[i]);
     }
     else
     {
         printf("\n%c is a digit", arr[i]);
     }
     }
printf("\n");
}


Output

8 is a digit
á is not a digit
5 is a digit
Z is not a digit
ý is not a digit


See also

iswdigit, defns

Feedback

For additional information or queries on this page send feedback

© 2008 Nokia Corporation. All rights reserved. This documentation can be used in the connection with this Product to help and support the user.

Top