Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!ceres.physics.uiowa.edu!news.iastate.edu!john Newsgroups: comp.lang.c Subject: Re: isalpha in ctype.h Message-ID: <1991Mar25.013752.1975@news.iastate.edu> From: john@iastate.edu (Hascall John Paul) Date: Mon, 25 Mar 1991 01:37:52 GMT Sender: news@news.iastate.edu (USENET News System) References: <1991Mar20.112543.5515@ericsson.se> Organization: Iowa State University, Ames, IA Lines: 24 In article collinsa@p4.cs.man.ac.uk (Adrian Collins) writes: }In <1991Mar20.112543.5515@ericsson.se> etxnisj@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@iastate.edu Ames, IA 50011 (515) 294-9551