The \c escape
Doug Gwyn
gwyn at brl-smoke.ARPA
Thu Jun 23 01:45:21 AEST 1988
In article <963 at ficc.UUCP> peter at ficc.UUCP (Peter da Silva) writes:
>In article <8127 at brl-smoke.ARPA>, gwyn at brl-smoke.ARPA (Doug Gwyn ) writes:
>> Multiple-character character constants are unportable and
>> considered bad style. They're only permitted because they were in previous
>> practice. Many of us don't think you should ever try to make use of them.
>(1) OK, how do you spell "\x234\c5"? "\x234""5"?
Sure. What's wrong with using the more general facility for strings?
>(2) What's wrong with a readable and maintainable way of initialising a
> 32-bit unsigned integer to 0x464F524DL? You prefer that (or ('F'<<24)|
> ('O'<<16)|('R'<<8)|('M')) to 'FORM'?
I would prefer that you not depend on being able to jam 'FORM' into
an int in the first place. It will obviously not work on a 16-bit
implementation.
If you nonetheless feel you have to use a kludge a la troff, try
#define PACK(c1,c2) ((c1)<<8 | (c2))
which at least is portable across 8-bit byte implementations.
More information about the Comp.std.c
mailing list