cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
verify user input
verify user input
Mar 16, 2008 at 4:09pm UTC
fubar
(11)
Hello all,
I would like to verify if a user input is of a certain type.
Say, I would like to make sure that a user only enters integers, or characters.
Is there an easy way to do so?
Thanks for your help
Mar 16, 2008 at 4:56pm UTC
vince1027
(151)
Two commonly used functions to check for alphanumerics:
1
2
int
isalpha (
int
c );
int
isdigit (
int
c );
both functions are defined in ctype.h of the C library. If you want them on a C++ program, you need to do: #include<cctype>
more information:
http://www.cplusplus.com/reference/clibrary/cctype/isalpha.html
http://www.cplusplus.com/reference/clibrary/cctype/isdigit.html
Topic archived. No new replies allowed.