answersLogoWhite

0


Best Answer

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 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.

User Avatar

Wiki User

โˆ™ 2015-07-17 17:27:37
This answer is:
๐Ÿ™
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
User Avatar
Study guides
๐Ÿ““
See all Study Guides
โœ๏ธ
Create a Study Guide

Add your answer:

Earn +20 pts
Q: What is a NULL Pointer?
Write your answer...
Submit
Related questions

What is the difference between a null pointer and a null macro?

A null pointer is a pointer variable with the value 0. A null macro is a macro that defines the NULL symbol (typically 0L on a 32-bit system).


What is a null macro what is the difference between a null pointer and a null macro?

NULL Macro is simply what is defined as 0 in a macro provided by the libraryNull pointer is a pointer which has 0 or NULL value stored and points to nowhwere still it points to 0x00 i.e. the first memory location of the OSNull pointer != Uninitialized pointer because an uninitialised pointer can point anywhere in the memory location ...but a NULL pointer surely points to no where(but still behind the scene we can say that it only points to 0x00). Never we can retrive a Null pointer location using th"&" operator..neither will malloc/calloc return NULL IF THERE IS SPACE IN THE MEMORY. NULL pointer is unique !!nishantnitb@aol.com


What is the use of null pointer?

Pointer is a variable that stores address of a variable . A NULL Pointer a pointer that doesn't point to anything, it is a literal zero .Some people ,notably C++ programmers, prefer to use 0 rather than NULL.


What is the difference between void pointers and null pointers?

A void pointer is a pointer that has no type information attached to it.A null pointer is a pointer that points to "nothing". A null pointer can be of any type (void included, of course).


What is NULL Pointer?

There are times when it is necessary to have a pointer that doesn't point to anything. The macro NULL, defined in , has a value that's guaranteed to be different from any valid pointer. NULL is a literal zero, possibly cast to void* or char*.


What is null pointer error?

For example, if you write NULl instead of NULL.


Why you get null pointer assignment error occurs in c?

You haven't assigned the pointer yet, so it's initialized as NULL, or you're trying to assign NULL to the value of the pointer. You have to check if the value is NULL before you use it, or you'll end up with errors just like this.


When you let your pointer linger over an object the pointer is?

The pointer is non-NULL.


What is the meaning of Null Null?

its just an programming error, null definition in Programming is to represent the thing referred to by an uninitialised pointer.


What is null pointer and is it same as an uninitialized pointer?

An uninitialized pointer is a pointer that has not been assigned a value; it's uninitialized.The value of an uninitialized pointer is undefined (it could be anything).A null pointer is simply a pointer that has a value of NULL.A word of advice: initialize your pointers to NULL.This allows you to see that the pointer is invalid; to check if an uninitialized pointer is valid is quite impossible.Examples:Uninitialized:int *myPointer;Null-pointer:int *myNullPointer = NULL;Dereferencing either of these pointers is something you'll like to avoid.It is very common in a program to check for null pointers; some functions return NULL on failure, for example:struct Foo *result = doSomething();if (result == NULL) {printf("Error: The function doSomething() returned NULL);return;} else {printf("The result: %d", result->bar);}


What is null point in C programming?

I'm going to go out on a limp here, and guess you mean "Null Pointer." Well, it's a pointer to nothing. For most systems, it's 0, but rather use NULL instead.


Difference between void pointer and null pointer?

A Null pointer has the value 0. void pointer is a generic pointer introduced by ANSI. Before ANSI, char pointers are used as generic pointer. Generic pointer can hold the address of any data type. Pointers point to a memory address, and data can be stored at that address.


What is the size of null pointer?

A NULL pointer has the same size as a non NULL pointer. NULL means that the pointer has been set to the NULL value that is usually zero (0) but the NULL value is at the digression of the compiler manufacture (and may have a value other than zero) so a pointer should always be set to the NULL value and not zero. Current compilers (32 and 64 bit, Intel chip) have a pointer size of 4 (8 bit) bytes. It should be noted that the number of bits in any data type is at the compiler manufactures digression but is heavily influenced by the computer hardware. void *p= NULL; printf ("%d\n", sizeof (p)); or printf ("%d\n", sizeof (void *));


What is the difference between void pointer 0 and NULL.?

If by 'void pointer 0' you mean '(void *)0', then it is equal to NULL.


What are different type of pointers?

Pointer is a variable that is used to store the memory address of another variable. There are differenr types of pointers: NULL pointer THIS pointer VOID pointer NEAR pointer HUGE pointer FAR pointer WILD pointer


How do you Swap two adjacent elements by adjusting only the pointers and not the data using singly linked list?

Starting with a pointer to the pointer to the first element (p1**), verify the first pointer is not null (*p1 != null), retrieve the pointer to the second element (*p2 = *p1.next) and verify it is also not null (*p2 != null), and then retrieve the pointer to the third element (*p3 = *p2.next). Note that *p3 might be null, but *p1 and *p2 must not be null, or the swap can not be performed. Note that using pointer to pointer syntax allows you to treat pointer to first element the same as pointer to subsequent element, i.e. to not need to handle the special case. Also, since you do need to modify the pointer, you need a pointer to the pointer. Set *p1 = *p2, *p3 = *p1, and *p2 = *p3. Note that these assignments must be done using the original values, not the intermediate value, so you will need some temp pointers. The end result is that **p1 will be ordered after **p2.


Java null pointer exceptions?

A null pointer exception in java comes when you are trying to perform any action on an object that isnt initialized/has a value i.e., is a NULL Value Ex: private String s; //declare a string if(s.equals("test")){ //do something.. } You will get a null pointer in the if condition because you are checking a value that is null which is not allowed..


What is dangling pointer reference?

Whenever memory that was in use, and was referred to by a pointer variable, is freed, and the pointer variable is not updated accordingly (setting it to NULL, for example), the pointer variable is considerred to be a dangling pointer reference.


What is pointer initialization?

Assigning an initial value to a pointer variable. Example: int *p= NULL;


How will you declare null pointer in C?

#define NULL ((void *)0) /* defined in <stddef.h> */ const char *mynullvar = NULL;


Java does not support pointers then what is null pointer exception?

A null pointer exception is thrown when you are trying to manipulate an object that is null. It is just the name and does not have any relevance to the pointers as in C Example: ArrayList lst = null; Object obj = lst.get(0); In the first line we have declared an array list. Without initializing it we have tried to access the element in the 0th position. This would cause a null pointer exception.


What does the error 'Null Pointer Assignment' mean and what causes this error?

Null pointer assignment means assigning a value to 0th location or accessing 0th location which is run time error should be avoided.


Null Pointer Assignment?

This error message means that somewhere in your program you have used a pointer-varible containing NULL-value. (Within an actual OS it with stop the program immediately, but in MS-DOS it doesn't.)


Is it legal to pass a null pointer as the first argument to realloc?

yes.


What is null object in c plus plus?

a pointer that is not pointing to anything