Is there a good example of how toupper() works?

Richard A. O'Keefe ok at goanna.cs.rmit.oz.au
Mon Nov 12 23:58:59 AEST 1990


In article <1990Nov12.040933.5419 at sq.sq.com>, msb at sq.sq.com (Mark Brader) writes:
> 	#  define IS_CTYPABLE(c) (((c) < UCHAR_MAX && (c) >= 0) || (c) == EOF)

Knowing that EOF is -1, one could do this with one evaluation of (c)
-- always a courteous thing to do in a macro --
	# define IS_CTYPABLE(c) \
	((unsigned)((c)+EOF) < (unsigned)(UCHAR_MAX+EOF))

I've never used isascii() myself because I had always constructed the
program so that I knew the codes were in range without needing a run-
time test; if you've got something you _think_ is a character and it's
outside the range that the ctype macros can handle what can you do but
report an error, and why leave it that late to check?
-- 
The problem about real life is that moving one's knight to QB3
may always be replied to with a lob across the net.  --Alasdair Macintyre.



More information about the Comp.lang.c mailing list