Checking the user input.

This is a discussion on Checking the user input. within the C Programming forums, part of the General Programming Boards category; What would be a simple way to see wether the user indeed inputs an int and not a char? Thank ...

  1. #1
    Novice.
    Join Date
    Oct 2005
    Posts
    88

    Checking the user input.

    What would be a simple way to see wether the user indeed inputs an int and not a char?

    Thank You.

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    Search this forum and copy and paste any of the numerous examples already posted.

    That's the simplest way I know.
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  3. #3
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,473
    Quote Originally Posted by omnificient View Post
    What would be a simple way to see wether the user indeed inputs an int and not a char?

    Thank You.
    use strtol and check if the end pointer is really set to the end of line by this function
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to limit user input to a certain number of digits?
    By NewbGuy in forum C Programming
    Replies: 7
    Last Post: 05-08-2009, 09:57 PM
  2. timed user input
    By sainiabhishek in forum C Programming
    Replies: 4
    Last Post: 04-01-2009, 11:59 AM
  3. Truncating user input
    By CS_Student8337 in forum C Programming
    Replies: 10
    Last Post: 03-19-2009, 12:34 AM
  4. Replies: 4
    Last Post: 04-21-2004, 04:18 PM
  5. checking user input for "type"
    By itld in forum C++ Programming
    Replies: 1
    Last Post: 12-24-2001, 04:25 AM

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