two chars at once...
Doug Gwyn
gwyn at smoke.BRL.MIL
Thu Sep 14 21:30:34 AEST 1989
In article <QZ3bmsW00WB4E5BEob at andrew.cmu.edu> sr16+ at andrew.cmu.edu (Seth Benjamin Rothenberg) writes:
>One of the nasty things it does is treat 2 characters
>as a single 2-byte integer.
> if "ax" = mystr -> if mystr[1]=>C1D9 (or something like that)
> mystr = "AX"
>Should I just change this call to use macros, like
> if cmp2("ax", mystr);
> cpy2(mystr, "AX");
>or is a more direct (kludgy?) way possible?
The direct equivalent in C would be to use multi-character character
constants such as 'AX', which are ints containing the multiple
character codes "somehow". The details of how they are represented
are implementation-dependent; however, it is probable that 'AX' would
be equal to either 'A'<<CHAR_BIT|'X' or 'X'<<CHAR_BIT|'A'.
Using 2-character strings would be more portable, of course.
More information about the Comp.lang.c
mailing list