C语言中isupper的宏定义是什么?
我想知道isupper"宏是如何在 C/C++ 中定义的.能否请您提供相同的信息或指向我可用的资源.我尝试查看 ctype.h 但无法弄清楚.
I want to know how the "isupper" macro is defined in C/C++. Could you please provide me the same or point me to available resources. I tried looking at ctype.h but couldnt figure it out.
推荐答案
它是由实现定义的――每个供应商都可以而且通常会以不同的方式来做.
It's implementation defined -- every vendor can, and usually does, do it differently.
最常见的通常涉及特征"表 - 每个字符都有一个元素的数组,该元素的值是一组标志,表示有关字符的详细信息.一个例子是:
The most common usually involves a "traits" table - an array with one element for each character, the value of that element being a collection of flags indicates details about the character. An example would be:
traits[(int) 'C'] = ALPHA | UPPER | PRINTABLE;
在这种情况下,isupper() 将类似于:
In which case,, isupper() would be something like:
#define isupper(c) ((traits[(int)(c)] & UPPER) == UPPER)
相关文章