Функция isalpha
Функция isalpha проверяет аргумент, передаваемый через параметр сharacter , является ли он строчной или прописной буквой алфавита.
Обратите внимание на то, что результат, возвращаемый функцией после проверки аргумента, на предмет принадлежности его к алфавиту, зависит от используемого языка. По умолчанию, в С++ символы, которые могут быть удачно преобразованы функциями isupper и islower являются символами алфавита.
Подробно ознакомиться с возвращаемыми результатами функций, для каждого символа стандартного набора символов ASCII вы можете тут.
В С++ локализованная версия функции isalpha определена в заголовочном файле <locale> .
Параметры:
- character
Символ для проверки, передается в функцию как значение типа int , или EOF .
Возвращаемое значение
Значение, отличное от нуля (т.е. истинно), если аргумент функции — это буква алфавита.
ISALPHA
Feature Test Macro Requirements for glibc (see feature_test_macros (7)):
isascii (): _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE
isblank (): _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L;
or cc -std=c99
isalnum_l (), isalpha_l (), isblank_l (), iscntrl_l (), isdigit_l (), isgraph_l (), islower_l (), isprint_l (), ispunct_l (), isspace_l (), isupper_l (), isxdigit_l (): Since glibc 2.10: _XOPEN_SOURCE >= 700 Before glibc 2.10: _GNU_SOURCE
isascii_l (): Since glibc 2.10: _XOPEN_SOURCE >= 700 && (_SVID_SOURCE || _BSD_SOURCE) Before glibc 2.10: _GNU_SOURCE
DESCRIPTION
The functions with the "_l" suffix perform the check based on the locale specified by the locale object locale . The behavior of these functions is undefined if locale is the special locale object LC_GLOBAL_LOCALE (see duplocale (3)) or is not a valid locale object handle.
The list below explains the operation of the functions without the "_l" suffix; the functions with the "_l" suffix differ only in using the locale object locale instead of the current locale. isalnum () checks for an alphanumeric character; it is equivalent to (isalpha( c ) || isdigit( c )) . isalpha () checks for an alphabetic character; in the standard "C" locale, it is equivalent to (isupper( c ) || islower( c )) . In some locales, there may be additional characters for which isalpha () is true—letters which are neither uppercase nor lowercase. isascii () checks whether c is a 7-bit unsigned char value that fits into the ASCII character set. isblank () checks for a blank character; that is, a space or a tab. iscntrl () checks for a control character. isdigit () checks for a digit (0 through 9). isgraph () checks for any printable character except space. islower () checks for a lowercase character. isprint () checks for any printable character including space. ispunct () checks for any printable character which is not a space or an alphanumeric character. isspace () checks for white-space characters. In the C and POSIX locales, these are: space, form-feed ( ‘\f’ ), newline ( ‘\n’ ), carriage return ( ‘\r’ ), horizontal tab ( ‘\t’ ), and vertical tab ( ‘\v’ ). isupper () checks for an uppercase letter. isxdigit () checks for hexadecimal digits, that is, one of
0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F .
RETURN VALUE
ATTRIBUTES
Multithreading (see pthreads(7))
VERSIONS
CONFORMING TO
POSIX.1-2008 marks isascii () as obsolete, noting that it cannot be used portably in a localized application.
POSIX.1-2008 specifies isalnum_l (), isalpha_l (), isblank_l (), iscntrl_l (), isdigit_l (), isgraph_l (), islower_l (), isprint_l (), ispunct_l (), isspace_l (), isupper_l (), and isxdigit_l ().
C isalpha()
The isalpha() function checks whether a character is an alphabet or not.
In C programming, isalpha() function checks whether a character is an alphabet (a to z and A-Z) or not.
If a character passed to isalpha() is an alphabet, it returns a non-zero integer, if not it returns 0.
The isalpha() function is defined in <ctype.h> header file.
C isalpha() Prototype
Function isalpha() takes a single argument in the form of an integer and returns an integer value.
Even though, isalpha() takes integer as an argument, character is passed to isalpha() function.
Internally, the character is converted into the integer value corresponding to its ASCII value when passed.
isalpha() Return Value
| Return Value | Remarks |
|---|---|
| Zero (0) | If the parameter isn’t an alphabet. |
| Non zero number | If the parameter is an alphabet. |
Example: C isalpha() function
Output
Note: You can get a different non-zero integer when alphabetic character is passed to isalpha() on your system. But, when you pass non-alphabetic character to isalpha(), it always returns 0.
isalpha
Checks if the given character is an alphabetic character, i.e. either an uppercase letter ( ABCDEFGHIJKLMNOPQRSTUVWXYZ ), or a lowercase letter ( abcdefghijklmnopqrstuvwxyz ).
In locales other than "C" , an alphabetic character is a character for which isupper() or islower() returns true or any other character considered alphabetic by the locale. In any case, iscntrl() , isdigit() , ispunct() and isspace() will return false for this character.
The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF .
Contents
[edit] Parameters
| ch | — | character to classify |
[edit] Return value
Non-zero value if the character is an alphabetic character, zero otherwise.