Path: utzoo!attcan!uunet!lll-winken!ames!xanth!mcnc!rti!xyzzy!throopw From: throopw@xyzzy.UUCP (Wayne A. Throop) Newsgroups: comp.lang.c Subject: Re: How to use toupper() Message-ID: <2792@xyzzy.UUCP> Date: 12 Jan 89 20:01:56 GMT References: <2537@xyzzy.UUCP> <189@becker.UUCP> <9256@smoke.BRL.MIL> <2581@ficc.uu.net> <1989Jan6.231955.7445@sq.uucp> <11391@haddock.ima.isc.com> Organization: Data General, RTP NC. Lines: 30 > karl@haddock.ima.isc.com (Karl Heuer) >> msb@sq.com (Mark Brader) >>The best you can do is to avoid "char" altogether and use "unsigned char". >>You probably have to do it throughout the program, in fact. > If the program has to be strictly conforming, you may be right. (But then > string literals, and functions that expect `char *' arguments, may screw > things up; casting the pointers ought to be safe, though.) If (ah say *IF*) it ought to be safe to cast pointers between (char *) and (unsigned char *) types, why can't the problematical case conversion be done like so: unsigned char *p; char *s; ... for( p=(unsigned char *)s; *p; ++p ) *p = toupper( *p ); But on the other hand... if the above code is unsafe (and I see nothing in dpANS which makes it safe), why would it be safe to use unsigned characters hither and thither and simply cast pointers to these to apply standard signed-character-expecting library routines to them? (Gad, don't the simplest issues turn out to be cans of worms at times?) -- "I really ought to do better next year." "It's the 'ought' that counts." --- paraphrase of Bloom County -- Wayne Throop !mcnc!rti!xyzzy!throopw