where is null defined?
if its not defined, how can i go about making my own null to use with pointers?
i thought null was defined as (void*)0 or (void*)&0
or something like that
thanks for the help!
where is null defined?
if its not defined, how can i go about making my own null to use with pointers?
i thought null was defined as (void*)0 or (void*)&0
or something like that
thanks for the help!
:/usr/include$ grep -r "#define NULL" *
g++-3/streambuf.h:#define NULL (__null)
g++-3/streambuf.h:#define NULL (0)
linux/stddef.h:#define NULL 0
linux/stddef.h:#define NULL ((void *)0)
mysql/mysql_com.h:#define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
pth.h:#define NULL (void *)0
rpc/clnt.h:#define NULLPROC ((u_long)0)
rpc/xdr.h:#define NULL_xdrproc_t ((xdrproc_t)0)
>where is null defined?
Perhaps you mean NULL.
http://www.eskimo.com/~scs/C-faq/q5.4.html
>if its not defined, how can i go about making my own null to use with pointers?
Don't. Use NULL or 0.
You may want to review null pointers.
http://www.eskimo.com/~scs/C-faq/s5.html
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
revelation.
null, nul and NUL are'nt defined. NULL of course is.
I generally consider null, nul and NUL to be '\0' whilst NULL is ((void *)0)
Take a peek in stdio.h you may find it's been defined there.
It may also be defined in other various locations.
R.I.P C89
The C language defines a macro, NULL, that is the equivalent of 0 in pointer context. Past that it's all individual terminology, but many people make the following distinctions:
null, NULL - A pointer that points to nothing
nul, NUL - The '\0' character
In the end they all evaluate to 0 though.
My best code is written with the delete key.