Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!wuarchive!udel!rochester!pt.cs.cmu.edu!o.gp.cs.cmu.edu!andrew.cmu.edu!jh4o+ From: jh4o+@andrew.cmu.edu (Jeffrey T. Hutzelman) Newsgroups: comp.lang.c Subject: Re: Seven Original Sins of K&R (Long) Message-ID: <4b0G9HO00VonAlDGJa@andrew.cmu.edu> Date: 26 Sep 90 21:49:07 GMT References: <12780@sdcc6.ucsd.edu>, <1990Sep26.124303.10527@eua.ericsson.se> Organization: Carnegie Mellon, Pittsburgh, PA Lines: 44 In-Reply-To: <1990Sep26.124303.10527@eua.ericsson.se> rv@erix.ericsson.se (Robert Virding) writes: >In article <12780@sdcc6.ucsd.edu>, mautner@odin.ucsd.edu (Craig >Mautner) writes: >> Seven Original Sins of K&R >> by Philip J. Erdelsky > >> II >> Some compilers don't even object when >>you assign an integer constant to a pointer without a >>typecast, especially when the constant happens to be >>zero. Don't blame the compiler. The poor thing can't >>tell the difference between a zero integer constant and >>"NULL". > >According to the language definition assigning a zero to a pointer is >perfectly legal, the compiler shouldn't complain. All C compilers I >have seen will complain for any other integer. For the 50 million'th >time in this group, there is no difference between zero and NULL. I know of one compiler (on a 16-bit micro) that will not complain if you use any other integer or long int. Pointers on that machine are (exaclty) same as unsigned long ints, and the compiler lets you say void function(void) { unsigned char *pointer; unsigned long int integer; integer=0xE0C000; for(pointer=integer;!(*pointer && 0x80);); /* wait for keypress */ printf("%#04x",*pointer & 0x7F); /* strip off flag bit */ integer=0xE0C010; *pointer=0; /* reset keyboard latch and/or advance buffer */ } which will wait for a keypress and print out its ASCII value (on an Apple IIgs, under ORCA/C 1.0 or 1.1). ----------------- Jeffrey Hutzelman America Online: JeffreyH11 Internet/BITNET:jh4o+@andrew.cmu.edu, jhutz@drycas.club.cc.cmu.edu >> Apple // Forever!!! <<