Thread: isdigit confusion

  1. #1
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002

    isdigit confusion


    According to documentation, isdigit returns a non-zero value is the value passed to it is a decimal integer, 0 otherwise. BUt when i tested it in a simple program it does the opposite. Any ideas?
    #include <stdio.h>
    #include <ctype.h>
    int main()
       int c = 33;
       if ( isdigit( c ) == 0 )
          printf( "not an integer\n" );
       return 0;

  2. #2
    Join Date
    Aug 2001
    Groningen (NL)
    The definition of isdigit: The isdigit function


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

    2 The isdigit function tests for any decimal-digit character (as defined in 5.2.1).
    So it is about decimal-digit characters.... and not about decimal values.

    isdigit (5) -> FALSE
    isdigit ('5') -> TRUE

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. isdigit woes
    By kryonik in forum C Programming
    Replies: 3
    Last Post: 10-14-2005, 05:10 PM
  2. isdigit()
    By kermit in forum C Programming
    Replies: 3
    Last Post: 03-19-2004, 09:59 PM
  3. I read the FAQ on isdigit() but...
    By CaptainJack in forum C Programming
    Replies: 5
    Last Post: 03-16-2004, 06:03 AM
  4. #include cctype and the isdigit
    By nextus in forum C++ Programming
    Replies: 2
    Last Post: 12-26-2002, 07:55 PM
  5. Correct use of isdigit
    By DocDroopy in forum C Programming
    Replies: 3
    Last Post: 08-05-2002, 07:22 AM