ctype functions

Stan Brown stan at Dixie.Com
Tue Mar 26 09:25:54 AEST 1991


john at iastate.edu (Hascall John Paul) writes:

=>In article <collinsa.669647114 at p4.cs.man.ac.uk> collinsa at p4.cs.man.ac.uk (Adrian Collins) writes:
=>}In <1991Mar20.112543.5515 at ericsson.se> etxnisj at eos8c21.ericsson.se (Niklas Sjovall) writes:
=>}>I want to use a macro defined in ctype.h ... i don't fully understand it.
=>}>#define	isalpha(c)	((_ctype_+1)[c]&(_U|_L))
=>}>It's the part (_ctype_+1)[c] i don't understand.

=>}For some reason the first entry in the array isn't used for holding
=>}character type information (beats me why) ...

=>     The is????? macros are defined over the set (-1 ... 255) hence
=>the need to offset by 1 to `align' with C's "start at 0" arrays (-1
=>is for EOF).  This is so stuff like the following works correctly.

=>          do {
=>             c = getchar();
=>                 :
=>             if (isalpha(c)) fribbles(c);
=>                 :
=>          } while (c != EOF);

	There was an execelent discussion of this subject about two months
	ago in _C_USERS_ magazine.  It was a part of a serries that
	will eventually cover all the standard headers for an ANSI compliiant
	compiler.


-- 
Stan Brown	P. c. Design 	404-363-2303	Ataanta Ga.
(emory|gatech|uunet) rsiatl!sdba!stan           	"vi forever"
"Operating Systems, Like Editors Are Religions" -- Armando Stettner



More information about the Comp.lang.c mailing list