isdigit()

This is a discussion on isdigit() within the C++ Programming forums, part of the General Programming Boards category; Im new to C++. In school we have to write a program that will prompt user input , throw it ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    2

    isdigit()

    Im new to C++. In school we have to write a program that will prompt user input , throw it in an array. and analize the data, and if anything in the array is anything other than an int, to through an error stating that the user did not enter an integer.
    WHEW! Ok, that said, Im using cin.get to read the data entered. And using If satements for the isdigit(cInput); cInput being the data entered by the user. My problem comes when the compiler sees cInput as a string entered by the user. (I declared it as char)
    And it cant convert char * to int. I tried doing atoi(cInput) to convert the char string to int, but it makes no difference to the compiler. HELP !!

  2. #2
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    Post some code, yo. Lets see what you've done thus far. (and please for our viewing pleasure paste your code within a code block - begins with [code] and ends with [/code])

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    491
    Helpful hint: isdigit checks 1 character at a time, not a whole string.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. isdigit woes
    By kryonik in forum C Programming
    Replies: 3
    Last Post: 10-14-2005, 05:10 PM
  2. isdigit()
    By kermit in forum C Programming
    Replies: 3
    Last Post: 03-19-2004, 08:59 PM
  3. I read the FAQ on isdigit() but...
    By CaptainJack in forum C Programming
    Replies: 5
    Last Post: 03-16-2004, 05:03 AM
  4. #include cctype and the isdigit
    By nextus in forum C++ Programming
    Replies: 2
    Last Post: 12-26-2002, 06:55 PM
  5. Correct use of isdigit
    By DocDroopy in forum C Programming
    Replies: 3
    Last Post: 08-05-2002, 07:22 AM

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