Obfuscated C and Other Mysteries

Don Libes

Mentioned 1

Software -- Programming Languages.

More on Amazon.com

Mentioned in questions and answers.

I have seen the following macro definitions in a coding book.

#define TRUE  '/'/'/'
#define FALSE '-'-'-'

There was no explanation.

Please explain to me how these will work as TRUE and FALSE.

Jay already answered why the values of these expressions are 0 and 1.

For history sake, these expressions '/'/'/' and '-'-'-' come from one of the entries of 1st International Obfuscated C Code Contest in 1984:

int i;main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hell\
o, world!\n",'/'/'/'));}read(j,i,p){write(j/p+p,i---j,i/i);}

(Link to the program here, there is a hint of what this program does in the IOCCC page above.)

Also if I remember correctly these expressions as obfuscated macros for TRUE and FALSE were also covered in "Obfuscated C and Other Mysteries" book by Don Libes (1993).