本文介绍了C中的isupper的宏定义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道在C/C ++中如何定义"isupper"宏.您能否提供与我相同的信息或向我指出可用资源.我尝试查看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)

这篇关于C中的isupper的宏定义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 13:54