[<<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()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson