isalpha in ctype.h
Hascall John Paul
john at iastate.edu
Mon Mar 25 11:37:52 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:
}>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);
--
John Hascall An ill-chosen word is the fool's messenger.
Project Vincent
Iowa State University Computation Center john at iastate.edu
Ames, IA 50011 (515) 294-9551
More information about the Comp.lang.c
mailing list