Results 1 to 4 of 4

Thread: notANumber in C? how?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2001
    Location
    Ottawa, Canada
    Posts
    181

    notANumber in C? how?

    i've done VB programming, and java, but i'm new to C, and i was wondering how i would be able to read a valid input.

    if the user inputs an invalid number, how do i check for that? java there is a command called notANumber returns a boolean, (or something very similar)...is there an equivalent in c?


    also is there a way to check if the int entered is too large? i'm trying to do something using "sizeof()", but not sure what i can do with it...
    any other functions or expressions i could use?



    i'm trying to stay away from trying and catching exceptions...
    thanx in advance

    --770
    Last edited by delta770; Feb 2nd, 2003 at 08:46 PM.

  2. #2
    Member
    Join Date
    Dec 2002
    Location
    Miami,FL
    Posts
    34
    <cctype> // C++
    <ctype.h> /* C */

    int isalnum(int c);
    int isalpha(int c);
    int isblank(int c); [added with C99]
    int iscntrl(int c);
    int isdigit(int c);
    int isgraph(int c);
    int islower(int c);
    int isprint(int c);
    int ispunct(int c);
    int isspace(int c);
    int isupper(int c);
    int isxdigit(int c);
    int tolower(int c);
    int toupper(int c);

    isalnum

    int isalnum(int c);

    The function returns nonzero if c is any of:

    a b c d e f g h i j k l m n o p q r s t u v w x y z
    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
    0 1 2 3 4 5 6 7 8 9

    or any other locale-specific alphabetic character.
    isalpha

    int isalpha(int c);

    The function returns nonzero if c is any of:

    a b c d e f g h i j k l m n o p q r s t u v w x y z
    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

    or any other locale-specific alphabetic character.
    isblank

    int isblank(int c); [added with C99]

    The function returns nonzero if c is any of:

    HT space

    or any other locale-specific blank character.
    iscntrl

    int iscntrl(int c);

    The function returns nonzero if c is any of:

    BEL BS CR FF HT NL VT

    or any other implementation-defined control character.
    isdigit

    int isdigit(int c);

    The function returns nonzero if c is any of:

    0 1 2 3 4 5 6 7 8 9

    isgraph

    int isgraph(int c);

    The function returns nonzero if c is any character for which either isalnum or ispunct returns nonzero.
    islower

    int islower(int c);

    The function returns nonzero if c is any of:

    a b c d e f g h i j k l m n o p q r s t u v w x y z

    or any other locale-specific lowercase character.
    isprint

    int isprint(int c);

    The function returns nonzero if c is space or a character for which isgraph returns nonzero.
    ispunct

    int ispunct(int c);

    The function returns nonzero if c is any of:

    ! " # % & ' ( ) ; <
    = > ? [ \ ] * + , -
    . / : ^ _ { | } ~

    or any other implementation-defined punctuation character.
    isspace

    int isspace(int c);

    The function returns nonzero if c is any of:

    CR FF HT NL VT space

    or any other locale-specific space character.
    isupper

    int isupper(int c);

    The function returns nonzero if c is any of:

    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

    or any other locale-specific uppercase character.
    isxdigit

    int isxdigit(int c);

    The function returns nonzero if c is any of:

    0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F

    tolower

    int tolower(int c);

    The function returns the corresponding lowercase letter if one exists and if isupper(c); otherwise, it returns c.
    toupper

    int toupper(int c);

    The function returns the corresponding uppercase letter if one exists and if islower(c); otherwise, it returns c.

    from CodeGoddess


    Hope this helps
    Death is always smiling down on us, the only thing we can do is smile back

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 2001
    Location
    Ottawa, Canada
    Posts
    181
    where did you get this??

    is there an online api for c anywhere?

    thanx for your help

    -770

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Lots. Search Google for CRT and reference.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width