Cover image for MathWorks
Logo

MathWorks

Engaged Employer

MathWorks

Add an Interview

Interview Question

Applications Support Engineering Interview

-

MathWorks

What is a null pointer?

Interview Answers

6 Answers

1

Definition: A null pointer is a general pointer (int *i, char *c, etc..,) except that the address stored in i, c doesn't correspond to any memory location. (i=0, c=0)

Anonymous on

0

NULL is "Pointing to nothing" It can be referenced as 0 or NULL or nil. The RHS will decide the value If the RHS is pointer then 0 is pointing to nothing, and if RHS is not pointer e.g. integer the 0 has integer 0 value. so NULL is actually defined by the compiler/library designer and it has to be type cast to other types when we assigned it to different datatype values. NULL has no datatype of its own. [void != NULL]

Anonymous on

0

On most of the operating systems, programs are not permitted to access memory at address 0 because that memory is reserved by the operating system. However, the memory address 0 has special significance; it signals that the pointer is not intended to point to an accessible memory location. But by convention, if a pointer contains the null (zero) value, it is assumed to point to nothing.

Anonymous on

0

I guess what the interview want to hear is that "do not forget to release the memory the pointer pointed to before set it to null"

Anonymous on

0

Once the memory is release using the delete command, the pointer is pointing to null. Now if we try to delete it again, the heap will be corrupt.

Anonymous on

1

A pointer that points to nowhere or an empty location.

Anonymous on

Add Answers or Comments

To comment on this, Sign In or Sign Up.