input checking

This is a discussion on input checking within the C Programming forums, part of the General Programming Boards category; a quick question I hope... the input for my program is supposed to be a number, is there an easy ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    1

    input checking

    a quick question I hope...

    the input for my program is supposed to be a number, is there an easy way of checking that the input is a number instead of some string of alphabetic characters?

    I thought of examing the input a character at a time and use the isdigit() function, but this would be tedious to convert into a floating point number once the validity of the input was verified.

    Any help would be greatly appreciated

    --kiki--

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    129
    char bar[10];
    fgets(bar, 10, stdin);
    double foo = atof(bar);

    ?
    kooma - t.h@iki.fi

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 03:42 PM
  2. Checking input
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 05-26-2002, 03:06 AM
  3. Checking input
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 05-10-2002, 09:00 AM
  4. checking if input is a number ?
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 12-06-2001, 08:07 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21