isalpha() Test whether a character is alphabetic

isalpha() Test whether a character is alphabetic

isalpha() returns nonzero for a letter in the current locale. Pass EOF or unsigned char; it does not decode UTF-8, and true need not equal 1.

Categoryctype.h character classes
KindLibrary function
Header<ctype.h>
C standardC89 / C90

📝 Syntax

int isalpha(int c);

⚙️ Parameters

c RequiredThe character to test, represented as an unsigned char value or EOF.

Returns: Returns a nonzero value if the character is alphabetic, and zero otherwise.

▶ Example

Edit the C code below and click Run; the server compiles and executes it:

Output:

Letters: 1
⚠️ Warning Passing a potentially negative plain char value causes undefined behavior; the example converts it to unsigned char first.
💡 Tip Classification functions return zero or nonzero; do not assume a true result is exactly 1.

📚 Related Tutorials

❓ FAQ

QWhy is isalpha often called as isalpha((unsigned char)c)?
AThe standard accepts only values representable as unsigned char, or EOF. On platforms with signed plain char, a negative value passed directly falls outside that domain.
QCan isalpha produce different results in different locales?
AYes. Alphabetic classification depends on the current locale. The default C locale guarantees A-Z and a-z, while other locales may classify additional characters as letters.
QCan isalpha directly classify a UTF-8 Chinese character or a complete wide character?
ANo. isalpha handles one value at a time, either EOF or a value representable as unsigned char; a multibyte UTF-8 sequence cannot be passed as one complete character. For wide characters, consider iswalpha() under an appropriate locale. When you need the full Unicode letter database and cross-platform consistency, use a dedicated Unicode library.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

Content reviewed by MOTO · Found an error? Report it

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏