Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!snorkelwacker.mit.edu!hsdndev!cmcl2!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: isalpha in ctype.h Message-ID: <15528@smoke.brl.mil> Date: 20 Mar 91 21:39:39 GMT References: <1991Mar20.112543.5515@ericsson.se> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 17 In article <1991Mar20.112543.5515@ericsson.se> etxnisj@eos8c21.ericsson.se (Niklas Sjovall) writes: -I want to use a macro defined in ctype.h on a Sun4 (4.03), but i don't -fully understand it. -The macro is: -#define _U 01 -#define _L 02 -extern char _ctype_[]; -#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? No, in fact that's a quite standard implementation of . The +1 is used to allow EOF (defined as -1) to also be used as the argument to the is*() macros. Note that some implementations will fail if fed arbitrary garbage for arguments to the is*() macros, for example any integer value more negative than -1.