Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!zaphod.mps.ohio-state.edu!think.com!mintaka!bloom-beacon!eru!hagbard!sunic!isgate!krafla!einari From: einari@rhi.hi.is (Einar Indridason) Newsgroups: comp.lang.c Subject: 10 commandments and the NULL pointer? Message-ID: <2390@krafla.rhi.hi.is> Date: 8 Nov 90 10:20:21 GMT Organization: University of Iceland Lines: 40 I just 'troff'-ed Henry Spencer's 10 commandments and read it. It is great and it is now hanging in my wall at home. However one question entered my mind: (a question that perhaps should be in the FAQ list, and perhaps is there?) The question is about NULL pointers. Suppose I have the following code: ------------------------------------------------------ #include 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 ); /* which form should I use? (that is, should I cast the NULL value */ /* to int pointer, double pointer, char pointer?) */ } ----------------------------------------- Thanks for your time. -- Internet: einari@rhi.hi.is | "Just give me my command line and drag UUCP: ..!mcsun!isgate!rhi!einari | the GUIs in the waste basket!!!!" General Surgeons warning: Masking the 8th bit can seriously damage your brain!!