answersLogoWhite

0

Solution to null pointer assignment error?

Updated: 8/17/2019
User Avatar

Wiki User

14y ago

Best Answer
Answer#ifndef NULL
# define NULL ((void*)0)
#endif

AnswerDon't use pointers that contain NULL-value. Eg:

int *myptr= NULL;
...
*myptr = 32; /* wrong */
User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Solution to null pointer assignment error?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

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

This error appears due to incorrect assignment to pointer and pointer tries to access illegal memory...


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.


What is 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.)


What does the error NULL Pointer Assignment means and what causes this error?

It means your computer has crashed and is caused by current microprocessor technology being in the early stages of development. Current experts expect this problem to disappear in about 10 - 25 years. Seriously many tens of thousands of things could have caused the problem in the first place - a single cause would be impossible to determine.


What does the error 'Null Pointer Assignment' mean?

The null pointer assignment error means your program has attempted to access a memory address that does not belong to your program. This typically occurs when accessing memory indirectly through a pointer: int* p = nullptr; *p = 42; // Error: null pointer assignment The above is the classic example of this type of error. The null address is typically the all-zeroes address (0x0) but, regardless of the physical address, it must never be accessed because it is a system address. We typically refer pointers to the null address when they are no longer in use or we don't have an address we can (yet) assign to them. Passing unchecked pointers to functions is another common cause: void f (int* p) { *p = 42; // potential error // ... } In the above example there's no guarantee p refers to a non-system address. Although we can easily test p is non-null before accessing it, that won't guarantee p refers to a non-system address. However, we can greatly reduce the risk of error by passing memory address via references instead of pointers: void f (int& r) { r = 42; // ... } There's still potential that r refers to a system address if the address were passed via a pointer, however there is seldom any need to use unchecked pointer variables in C++. References and resource handles (or smart pointers) eliminate the need for pointers and are actually more efficient than pointers because testing for null becomes largely redundant. The only time we really need a pointer is when "no object" is a valid argument: void f (int* p) { if (p == nullptr) { // the "no object" code } else { // code that operates on an object } }


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 a segmentation fault?

An error in which a running program attempts to access memory not allocated to it and core dumps with a segmentation violation error. This is often caused by improper usage of pointers in the source code, dereferencing a null pointer, or (in C) inadvertently using a non-pointer variable as a pointer.


What is a segment fault?

An error in which a running program attempts to access memory not allocated to it and core dumps with a segmentation violation error. This is often caused by improper usage of pointers in the source code, dereferencing a null pointer, or (in C) inadvertently using a non-pointer variable as a pointer.


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 did Farmville mean by 'You must purchase the null first'?

This was a programming error in Farmville, which has now apparently been fixed.A "null" programming error refers to a special value used in several languages to represent the thing referred to by an uninitialized pointer/database.


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

The pointer is non-NULL.


What is null on FarmVille?

its just an programming error in farmville .it would soon be alright null definition in Programming : A special value used in several languages to represent the thing referred to by an uninitialised pointer/database