Re: Passing NULL to a c function
- Posted by Mathew Hounsell <mfh03 at UOW.EDU.AU> Mar 16, 2000
- 515 views
Hello, Here is an explanation of : What is NULL? It is a symbolic constant (atually it's not, but don't worry) to indicate an impossible pointer. On most machines, and under most OS'es the first word of a processes address is part of reserved memory, therefore a process can never have data there. So address 0 is an impossible place to have data. So C and C++ define an invalid pointer as 0. NULL is just a more expressive way of writing it. For example if( avar != NULL ) { will make most C/C++ programmers think avar is a pointer. Where as with if( avar != 0 ) { avar could be of any type. So I recommend using NULL. However as NULL is not an official part of C++ Bjarne Stroustop (Spelling?) recomends you use 0. It is defined in the header file <stddef.h> ------------------------- Sincerely, Mathew Hounsell mat.hounsell at excite.com