PDA

View Full Version : checking for number in c++


Serex
06-11-2004, 06:21 AM
Hey i was just wondering if there was a function that test a variable to being a number.

such as the isNaN() function of javascript

Mhtml
06-11-2004, 09:01 AM
I guess you mean in a string?

Serex
06-11-2004, 02:56 PM
yeh say i have a cin >> linked to a string. is there anyway i can filter it so no numbers can be input.

Jason
06-11-2004, 09:49 PM
you would have to take each char and type cast it to an int for its ascii value and then check to see if its within the correct ascii range for non numbers...


Jason

Serex
06-12-2004, 12:06 AM
ok ty jason