Thread: Checking the user input.

  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
    Chappell Hill, Texas
    Posts
    2,332
    Search this forum and copy and paste any of the numerous examples already posted.

    That's the simplest way I know.
    Mainframe assembler programmer by trade. C coder when I can.

  3. #3
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    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
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

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, 05:25 AM