Jump to content

problem

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
hbk

hbk

    Learning Programmer

  • Members
  • PipPipPip
  • 71 posts
u am accepting a single character from the user. how do i test the value entered if it was a number

#2
fread

fread

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 787 posts
read up on the functions in the ctype.h header file... You may need isalpha() and isdigit(). Assuming you are using C. C++ may have something similar. (I dont know c++)
Perfection of means and confusion of ends seem to characterize our age. Albert Einstein :confused:

#3
wobin

wobin

    Newbie

  • Members
  • Pip
  • 3 posts
you can use
if (!(cin >> var_x){
// do stuff if it's not and int when your var was declared an int, or ... 
}