Jump to content

Null object: Difference between revisions

m
→‎{{header|C}}: clarify "pointer zero"
(→‎{{header|C}}: Move a sentence from Undefined values#C that fits better here.)
m (→‎{{header|C}}: clarify "pointer zero")
Line 96:
Classic BASIC does have the concept of un-initialised or undefined variables.
=={{header|C}}==
C has the null pointer., Bywritten conventionas "0", itwhose internal representation is often, [http://c-faq.com/null/varieties.html though not always], pointsthe tosame memoryas addressinteger zero. It is (supposedly) garanteed to be pointing to nothing, so receiving one of those likely means you are not looking at an object--<i>but</i>, there are occasions where changing content of a null pointer actually does something (say, on DOS); and a function that's supposed to return a pointer on success doesn't always return a 0 otherwise (e.g. mmap returns -1 for failure).
 
There is a very common macro, <code>NULL</code>, which evaluates to <code>(void*) 0</code> or an equivalent value. NULL is compatible with all pointer types, including both data pointers and function pointers.
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.