OT: Requesting C advice
Mike McCarty
Mike.McCarty at sbcglobal.net
Thu May 24 22:07:14 UTC 2007
Les wrote:
> On Thu, 2007-05-24 at 11:38 +0100, Alan Cox wrote:
>
>>>The DEC KAL10 stored 5 characters in a 36 bit word with one bit
>>>left over for anything you wanted to do with it! It used 7 bit ASCII,
>>>of course.
>>
>>Or 6 BCD characters or 4 8 (as 9) bit ASCII values. Ditto the Honeywell
>>L66. Character width as a compile option.
>>
>>Be very glad that today you don't have to fight that kind of thing. Don't
>>however assume in portable code that int is 32bits, long is 32bits,
>>pointers are 32bits and so on. C99 has proper types when you need to be
>>specific.
>>
>>Also be aware that some Linux ports have char as unsigned by default and
>>others as signed.
>
> Hi, Alan,
> I haven't seen a signed char since the 80's. I did run into it once
> on I think a ColecoVision package (don't ask!).
$ cat char.c
#include <stdio.h>
int main(void) {
char Chr;
Chr = -1;
printf("%d\n",Chr);
return 0;
}
$ gcc -o char char.c
$ ./char
-1
$ uname -a
Linux Presario-1 2.6.10-1.771_FC2 #1 Mon Mar 28 00:50:14 EST 2005 i686
i686 i386 GNU/Linux
So, on FC2, char is signed by default. I suspect that to be true
for all the Fedora Core releases.
> That would really mess up any algorithm parsing into memory, and
> would make dealing with solving some kinds of memory issues very
> difficult, I would think, although
I suspect you are conflating "signed char" with "a character in the
execution environment which, when its code is stored into a signed char,
results in a negative value."
Mike
--
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
Oppose globalization and One World Governments like the UN.
This message made from 100% recycled bits.
You have found the bank of Larn.
I can explain it for you, but I can't understand it for you.
I speak only for myself, and I am unanimous in that!
More information about the fedora-list
mailing list