boaz@lamont.ldgo.columbia.edu (richard boaz) (01/13/90)
my question regards the declaration of a character array as being unsigned as in: unsigned char directory[65]; i've been handed down a program which declares all of the arrays being used to store only ascii characters as unsigned. by definition, unsigned gives me use of the upper-most bit, yet ascii only accesses the lowest 7 bits. 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. thanks in advance, richard
davidsen@sixhub.UUCP (Wm E. Davidsen Jr) (01/16/90)
In article <2004@lamont.ldgo.columbia.edu> boaz@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@sixhub.uucp ...!uunet!crdgw1!sixhub!davidsen "Getting old is bad, but it beats the hell out of the alternative" -anon