Answered Most Recently
In Technology
What is a NULL Pointer?
A pointer variable which is declared but not initialized is called a NULL POINTER. ex: int *p; Please don't use the above. A NULL pointer is a specific value …assigned to a pointer, just like any other value. NULL is a language-specific designation, and is guaranteed to be comparable to, unlike uninitialized variables, which can have any value. That is: int *a; int *b = NULL; int *c = (int *) malloc(sizeof(char)); ( a b ) is NOT guaranteed to be true (in fact, in many common languages, it's most likely to be false) (a NULL ) is also usually not true. (b NULL ) is ALWAYS true. (a c) is usually not true, but could possibly be. (b == c) is NEVER true. NULL is a reserved word in most high-level languages, and indicates a specific value for assignment. It is commonly used to indicate that something has not yet been assigned a "real" value, or has had its contents deleted. It is an EXPLICIT value, and not just "undefined". In the context of pointers (which, remember, are really memory location addresses), a NULL pointer is one which has NO value, and thus does NOT point to any memory location. The difference between an uninitialized pointer and a NULL pointer is that most common languages do not specify what value an uninitialized pointer has upon creation (many, such as C, are assigned a random value), while a NULL pointer explicitly has NO value (which is the meaning of NULL). Many modern languages and compilers will assign NULL to a pointer upon initialization, but don't count on it. It is sloppy programming to do so, and can lead to many hard-to-find errors. (MORE)