oscarbonilla.com
13Apr/080

Another useless C99 tidbit

From page 18 of the C99 standard:

All occurrences in a source file of the following sequences of three characters (called trigraph sequences) are replaced with the corresponding single character.

??= #    ??( [     ??/ \
??) ]      ??' ^     ??< {
??! |      ??> }    ??- ~

No other trigraph sequences exist. Each ? that does not begin one of the trigraphs listed above is not changed.

Ok, so take the following C program:

??=include <stdio.h>
int
main(int argc, char *argv??(??))
??<
	printf("hello world\n");
??>

And compile it with the -trigraphs switch to gcc:

dirac src $ gcc -trigraphs -o trigraphs trigraphs.c
dirac src $ ./trigraphs
hello world

Combined with this you could seriously obfuscate your C code.

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.