Name
isalpha
Synopsis
Ascertains whether a given character is a letter of the alphabet
#include <ctype.h> intisalpha
( intc
);
The function isalpha()
tests whether its character argument is a letter of the alphabet. If
the character is alphabetic, isalpha()
returns a nonzero value (that
is, true
); if not, the function
returns 0 (false
).
Tip
Which characters are considered alphabetic depends on the
current locale setting for the localization category LC_CTYPE
, which you can query or change
using the setlocale()
function.
In the C
locale, which is
the default locale setting, the alphabetic characters are those
for which isupper()
or islower()
returns true. These are the 26
lowercase and 26 uppercase letters of the Latin alphabet, which
are the letters in the basic source and execution character sets
(see "Character Sets"
in Chapter 1).
Accented characters, umlauts, and the like are considered alphabetic only in certain locales. Moreover, other locales may have characters that are alphabetic, but are neither upper- nor lowercase, or both upper- and lowercase.
In all locales, the isalpha()
classification is mutually
exclusive with iscntrl()
,
isdigit()
, ispunct()
, and isspace()
.
Example
See the example for isprint()
in this
chapter.
See Also
The corresponding C99 function for wide characters, iswalpha()
; isalnum()
, isblank()
, iscntrl()
, isdigit()
, isgraph()
, islower()
, isprint()
, ispunct()
, isspace()
, isupper()
, isxdigit()
, setlocale()
Get C in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.