Library: Localization
Function
Locale convenience function that determines if a character is alphabetic or numeric
#include <locale> namespace std { template <class charT> bool isalnum(charT c, const locale& loc); }
The isalnum() function returns true if the character passed as a parameter is either part of the alphabet specified by the locale parameter or a decimal digit. Otherwise the function returns false. The check is made using the ctype facet from the locale parameter.
// // isalnum.cpp // #include <iostream> // for cout, endl #include <locale> // for isalnum int main () { std::cout << "Alphanumeric ASCII characters: "; // iterate for (char c = '\0'; c != '\177'; ++c) if (std::isalnum (c, std::cout.getloc ())) std::cout << c << ' '; std::cout << std::endl; return 0; } Program Output:
Alphanumeric ASCII characters: 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z
ctype, locale, isalpha(), iscntrl(), isdigit(), isgraph(), islower(), isprint(), ispunct(), isspace(), isupper(), isxdigit()
ISO/IEC 14882:1998 -- International Standard for Information Systems -- Programming Language C++, Section 22.1.3.1