unsigned char question

Wm E. Davidsen Jr davidsen at sixhub.UUCP
Tue Jan 16 12:38:10 AEST 1990


In article <2004 at lamont.ldgo.columbia.edu> boaz at lamont.ldgo.columbia.edu (richard boaz) writes:

| i've been handed down a program which declares all of the arrays being used
| to store only ascii characters as unsigned.  
	(a) if it's a C program you can't assume that the characters are
	    ASCII, they may well be something else.
	(b) it doesn't matter, since all printing characters have to be
	    positive integers, anyway. This is why char is allowed to be
	    unsigned in an implementation.

| someone has suggested to me that the compiler converts all signed variables
| to a value of long, yet i still fail to see how this helps me in the case of
| character strings.  anybody have a clue?  all responses are appreciated.

  I don't know what you mean by the above, unless char and long are the
same size the compiler can't just interchange them, and I find it hard
to believe that anyone would write a compiler which took a lot of effort
to make it slower.

  I conclude that either there's more to the program than you've
mentioned, or more than you know, or the unsigned is not required. There
isn't enough info to make any definitive statement, although I'm sure a
few people will ;-)
-- 
	bill davidsen - sysop *IX BBS and Public Access UNIX
davidsen at sixhub.uucp		...!uunet!crdgw1!sixhub!davidsen

"Getting old is bad, but it beats the hell out of the alternative" -anon



More information about the Comp.lang.c mailing list