Thread: C++ Checking Data Types

  1. #1
    G Fresh
    Guest

    Smile C++ Checking Data Types

    When I input an integer value using cin >> , how can I implement error-checking to make sure an integer was entered?

  2. #2
    Registered User Liam Battle's Avatar
    Join Date
    Jan 2002
    Posts
    114
    Well easy, just use the ctype.h

    You can use isdigit() or isalpha() function

    I also have the feeling you want to know how to check the size of the datatype that was used, you can use the sizeof keyword to do that...

    ie: a = sizeof b;

    those two things should help ya out
    Last edited by Liam Battle; 04-28-2002 at 10:47 PM.

  3. #3
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    Search the board, it has come up before. Look up cin.good(), cin.bad(), cin.fail().

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What are abstract data types
    By bhagwat_maimt in forum C++ Programming
    Replies: 4
    Last Post: 01-04-2007, 10:43 AM
  2. Errors
    By Rhidian in forum C Programming
    Replies: 10
    Last Post: 04-04-2005, 12:22 PM
  3. Very angry: "two or more data types in declaration"
    By quzah in forum C Programming
    Replies: 2
    Last Post: 06-04-2003, 07:16 AM
  4. C Programming Question
    By TK in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 07-04-2002, 07:11 PM
  5. Using enumerated data types
    By SXO in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2001, 06:26 PM