Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo C - <b>isdigit() test for digit</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
isdigit()                Test for Digit

 #include   <ctype.h>;

 int        isdigit(c)
 int        c;                           Integer value to be tested

    isdigit() tests if 'c' is a digit, in the set 0 - 9.

    Returns:    True (nonzero) if the integer satisfies the test
                condition or false (zero) if it does not.  The result is
                undefined if 'c' is other than an ASCII character or EOF.

      Notes:    isdigit() is a macro.

  -------------------------------- Example ---------------------------------

    The following statements open a file, read all the characters in, and
    total only those characters that are digits.

         #include <ctype.h>
         #include <stdio.h>             /* for fopen */

         FILE *stream;
         int ch;

         main()
         {
             int totl = 0;

             if ((stream = fopen("input.dat","r+")) != NULL) {
                 while (!feof(stream))
                       if (isdigit(ch = getc(stream)))
                          totl += ch;
             }
         }

See Also: isalnum() isalpha() isascii() iscntrl() isgraph()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson