answersLogoWhite

0

Depends on the language, the value of NULL (actual implementation and its value), and the definition of valid.

But in general, a pointer is an int, the value is a memory address of another data type (int, struct, or function, etc).

Because a pointer is an int, the value must be one of the integers defined.

if you have a derivative like:

#define NULL 0

then yes, NULL is a valid value for any pointer to functions

but "valid" is not the same as a "valid value". One may say "valid" means a pointer is pointing to an actual function, hence a pointer pointing to NULL is "Invalid".

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

How do you initialise pointers in functions?

Just like any other variable. Example: char *p = NULL;


What is the difference between equals 0 and equals NULL?

NULL is for pointers, 0, for numbers


Difference between null and empty in c plus plus?

NULL is a constant with the value zero. It is typically used with pointers to signify the pointer is valid, but it does not store a valid memory address. In other words it points at nothing in particular. It is nullified. All pointers that are not currently in use must be nullified to signify the fact they are not in use. The term empty applies to arrays that have no elements: empty arrays. We also use the term when referring to empty strings. A string is simply an array of char, but while null-terminated strings always have at least one char, the null-terminator, the string itself is empty.


What is the difference between null and void 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).


Solution to null pointer assignment error?

Answer#ifndef NULL# define NULL ((void*)0)#endifAnswerDon't use pointers that contain NULL-value. Eg:int *myptr= NULL;...*myptr = 32; /* wrong */


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.


How is free implemented in C language?

In C, the free function is used to deallocate memory that was previously allocated with functions like malloc, calloc, or realloc. It takes a pointer as an argument and releases the associated memory block back to the system, making it available for future allocations. After calling free, the pointer is no longer valid, and using it can lead to undefined behavior. It's important to ensure that you only free pointers that were previously allocated and not pointers that are NULL or pointing to stack memory.


What are the advantages of pointers in a program?

A pointer is simply a variable that stores a memory address and that allows that memory to be dereferenced. Unlike a reference, which must always refer to the object assigned to it, a pointer can refer to any object of the pointer's type, including null. A null pointer is simply a pointer that does not refer to any object. In languages that do not support pass by reference (such as C), pointers must be used to pass objects to functions. The pointer is passed by value, but the value is a memory address, which is the same as passing the object at that address. In languages that do support references (such as C++), references are useful when you need to guarantee an object exists because a reference can never be null. However, when passing an object to a function as an optional parameter, you must use a pointer because pointers can be null. Programmers must test pointers to ensure they are non-null before attempting to dereference them. References do not need to be tested; if a reference exists, it must refer to an object in memory.


Which is a valid declarations of a String?

String s1=null


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


Explain in detail in a binary tree of n nodes there are n plus 1 null pointers representing children?

Induction: 1. A tree of one node has two NULL-pointers. 2. Whenever you add a node to a tree, you remove one NULL-pointer (from the parent of the new node), and add two (the child's of the new node) in the same time.


Pointers to review in a napolcom examination?

government functions


What is meant by passing function to another function in c plus plus?

Just as pointers can point to variables, pointers can also point to functions. Thus you can pass function pointers to functions. In so doing, you can alter the behaviour of the function by having it call dynamically call arbitrary functions rather than just preset functions.


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.


Did Group functions include nulls in calculations?

no null values will not be included explanation when oracle parse the query the null values will be omitted for some reason if you want to consider null values you have to use some oracle functions like nvl or nvl2


What is the difference between uninitialized pointer and null pointer in c language?

A null pointer is a pointer that has been initialised with the NULL value (zero). An uninitialised pointer is one that has not be initialised to any value and will in fact store whatever value happened to reside in the pointer's own memory address at the point of instantiation. Uninitialised pointers are a clear sign of bad programming because the only safe way to determine if a pointer is valid or not is to compare its value with NULL. An uninitialised pointer will almost always be non-NULL, which means you run the risk of accessing memory that either does not belong to you, or is otherwise invalid. Most compilers include a debug switch to warn you when you attempt to access any uninitialised variable, which naturally includes pointer variables. This switch must be on at all times.Whenever you instantiate a pointer, always initialise it straight away, either by nullifying it, or by storing a valid memory address in it. When you are finished with the pointer, it's good practice to nullify it immediately, even if the pointer would subsequently fall from scope. If the pointer is to be immediately re-assigned, there is no need to nullify it (but it's good practice nonetheless). If you follow this practice at all times, you can be assured that any non-NULL pointer will always be pointing at something valid (and if it isn't, then you have some serious problems elsewhere in your code).As a rule of thumb, if you can use a reference rather than a pointer, use a reference. They are much easier to work with. Pointers should only be used if there's any possibility (however remote) that a reference could be NULL, because a NULL reference will completely invalidate your program (pointers can be NULL, but references can never be NULL). This is why functions such as malloc() and calloc(), and the C++ new operator all return pointers rather than references. You can only return a reference when an allocation is guaranteed to succeed, and a dynamic memory allocation simply cannot make that guarantee.


What is difference between null value and not null value?

In databases: Null Value: Represents the absence of a value or an unknown value. It indicates that the data is missing or not applicable. Not Null Value: Indicates that a field contains a valid, defined value. It means the data is present and has been explicitly set.


What is difference between code that is valid and code that is functional?

Validity is usually defined by the syntax of the language in question. Something that is not valid may give a compiler error. Invalid code may also give runtime errors (bugs in the code) like dereferencing NULL, uninitialized pointers, divide by zero, etc. But, you can write valid code that still doesn't do what it is supposed to do. That's not functional in that it does not perform the designed function (this recruit has been instructed but does not know).


What is virtual function table?

A virtual function table is a table of pointers to functions.


Can the domain of a function be the null set?

Yes, although it might not be a very useful function. However, there are times when you are studing properties of a set of functions and it is quite possible that a member of a set of functions has a null domain.