Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!mintaka!bloom-beacon!eru!hagbard!sunic!mcsun!hp4nl!sci.kun.nl!atcmpe!jc From: jc@atcmp.nl (Jan Christiaan van Winkel) Newsgroups: comp.lang.c Subject: Re: 10 commandments and the NULL pointer? Message-ID: <681@atcmpe.atcmp.nl> Date: 8 Nov 90 13:09:50 GMT References: <2390@krafla.rhi.hi.is> Organization: AT Computing, Nijmegen, The Netherlands Lines: 30 From article <2390@krafla.rhi.hi.is>, by einari@rhi.hi.is (Einar Indridason): # int do_something(int *par1, double *par2, char *par3) # { # /* do something with those pointers/parameters */ # /* return some value to tell how well we did */ # } # # # main() # { # ..... # # x = do_something(NULL, NULL, NULL); # /* is ^^^^ ^^^^ ^^^^ this right or should I write: */ # # x = do_something( (int *)NULL, (double *)NULL, (char *)NULL ); # } since you used prototypes, you can just as well use x = do_something(0, 0, 0); because the compiler knows the 0's are used in pointer context; it will automagically cast the value to the right type. Read the FAQ for more info on the NULL pointer, there's actually quite a lot to be told about it. JC -- ___ __ ____________________________________________________________________ |/ \ Jan Christiaan van Winkel Tel: +31 80 566880 jc@atcmp.nl | AT Computing P.O. Box 1428 6501 BK Nijmegen The Netherlands __/ \__/ ____________________________________________________________________