Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IsNumeric for C++

Status
Not open for further replies.

Kinl

Programmer
Mar 19, 2001
168
US
I've just started to program C++ and I was wondering is there a function that can test to see if a value is a character or not?

If so, what is it called, how do you use it and do I need to include a header file?

Thanx,

donn
 
No, there is no such function.
But instead, you could use this code:

...
int temp;
cin >> temp;

if ((toupper(temp) >= 'A') && (toupper(temp) <= 'Z'))
cout << &quot;It is a character&quot;;
...

you will have to include ctype.h to use toupper() that transforms a char to its upper case.
Best Regards,

aphrodita@mail.krovatka.ru {uiuc rules}
 
Yes,
There is a function isdigit(int) in ctype.h.
There are many function of character diagnostic like isalnum, isalpham, isupper, islower, isascii... John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top