How to use toupper()
Wayne A. Throop
throopw at xyzzy.UUCP
Fri Jan 13 06:01:56 AEST 1989
> karl at haddock.ima.isc.com (Karl Heuer)
>> msb at 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 <the-known-world>!mcnc!rti!xyzzy!throopw
More information about the Comp.lang.c
mailing list