Path: utzoo!attcan!uunet!midway!ncar!asuvax!cs.utexas.edu!usc!snorkelwacker!ira.uka.de!fauern!lan!weiske From: weiske@lan.informatik.tu-muenchen.dbp.de (Thomas Weiske) Newsgroups: comp.lang.c Subject: Re: more on TRUE and FALSE (side-comment) Keywords: C improved Message-ID: <4673@tuminfo1.lan.informatik.tu-muenchen.dbp.de> Date: 28 Sep 90 11:16:22 GMT References: <9@christmas.UUCP> Sender: news@lan.informatik.tu-muenchen.dbp.de Reply-To: weiske@lan.informatik.tu-muenchen.dbp.de (Thomas Weiske) Organization: Technische Universit"at M"unchen Lines: 47 I use some very useful header files because I cant remember the actual encoding of TRUE/FALSE. Actually I cant remember the correct writing of True or False, sometimes I prefer true and false depending on the context to get a nice C Program Layout. Here is the first one: ---x---x---x---x---x---x---x---x---x---x--- #define TRUE ((0)==(0)) #define True TRUE #define true True #define FALSE ((1)==(2)) #define False FALSE #define false False ---x---x---x---x---x---x---x---x---x---x--- To make the definitions more tolerant to typos you can add 'Treu' or 'Fasle' a.s.o. The interesting thing is the compatibility to all in this newsgroup suggested encodings of TRUE and FALSE without any loss of runtime speed! I also use many loops in my programs, but I dont like while(1), while(TRUE) or for(;;). This looks ugly and does not express the real meaning of the loop. I prefer: ---x---x---x---x---x---x---x---x---x---x--- #define ever (;;) ---x---x---x---x---x---x---x---x---x---x--- Now you can write: for ever {Stuff} I like it much more than 'forever' and the header file is 6 Bytes shorter! Now here is my solution to the self printing C program: ---x---x---x---x---x---x---x---x---x---x--- #include main(){ int c; FILE *f=fopen(__FILE__,"r"); while(f&&(c=getc(f))!=EOF)putchar(c); } ---x---x---x---x---x---x---x---x---x---x--- -- Thomas Weiske | Phone +89/2105 8136 weiske@lan.informatik.tu-muenchen.de | Fax +89/2105 8180 Technische Universit"at M"unchen