10 commandments and the NULL pointer?
Einar Indridason
einari at rhi.hi.is
Thu Nov 8 21:20:21 AEST 1990
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 <whatever_needs_to_be_included.h>
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 at 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!!
More information about the Comp.lang.c
mailing list