isalpha in ctype.h

Diomidis Spinellis dds at doc.ic.ac.uk
Tue Mar 26 20:59:25 AEST 1991


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:
>
[...]
>>#define	isalpha(c)	((_ctype_+1)[c]&(_U|_L))
> 
>>It's the part (_ctype_+1)[c] i don't understand. Could there be any
>>segmentation errors using this?
[...]
> For some reason the first entry in the array isn't used for holding
> character type information (beats me why), in which case the array is
> probably 257 in length presuming it isn't null terminated.

In this particular implementation _ctype_[0] holds the type value of
the special constant, defined in stdio.h, EOF which happens to have
the value of -1.  Thus _ctype_[0] has the type information for EOF (-1),
_ctype_[1] has the type information for character 0 etc.

Diomidis
-- 
Diomidis Spinellis                  Internet:                 dds at doc.ic.ac.uk
Department of Computing             UUCP:                    ...!ukc!icdoc!dds
Imperial College, London SW7        #define O(b,f,u,s,c,a)b(){int o=f(); ...



More information about the Comp.lang.c mailing list