Define CTRL(X)
Mike Zaleski
mzal at phoenix.UUCP
Fri Nov 14 13:13:39 AEST 1986
[...]
If one wants to do CTRL(X) and have it appear as though the character
'^X' was in the source text, this can be done without single quotes by:
# include <stdio.h>
# define CTRL(ZZ) ( (int) (*"ZZ" & 037) )
main () {
fprintf (stdout, "%d %d %d %d\n", CTRL(A), CTRL(B), CTRL(Z), CTRL(@));
exit (0);
}
This is not bulletproof, since CTRL(") will cause compilation errors and
some characters (like DEL) won't work with this. But if you just wanted
CTRL(A) .. CTRL(Z), this seems fairly straightforward.
It worked on our System Vr2 C compiler.
-- "The Model Citizen" Mike^Z
[ allegra, ihnp4 ] phoenix!mzal Zaleski at Rutgers.Arpa
More information about the Comp.lang.c
mailing list