Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the macro definition of isupper in C?

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.

like image 942
josh Avatar asked Aug 04 '10 06:08

josh


People also ask

What does Isupper mean in C?

isupper() function in C Language isupper() function in C programming checks whether the given character is upper case or not. isupper() function is defined in ctype. h header file. Syntax : int isupper ( int x );

What is macro define in C?

A macro is a piece of code in a program that is replaced by the value of the macro. Macro is defined by #define directive. Whenever a macro name is encountered by the compiler, it replaces the name with the definition of the macro.

What is the use of Islower () and Isupper () method in C?

The functions isupper() and islower() in C++ are inbuilt functions present in “ctype. h” header file. It checks whether the given character or string is in uppercase or lowercase.

Which is true about function is upper C?

Function isupper() takes a single argument in the form of an integer and returns a value of type int . Even though, isupper() takes integer as an argument, character is passed to the function. Internally, the character is converted to its ASCII for the check. It is defined in <ctype.


1 Answers

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;

In which case,, isupper() would be something like:

 #define isupper(c) ((traits[(int)(c)] & UPPER) == UPPER)
like image 94
James Curran Avatar answered Oct 13 '22 06:10

James Curran