Sollicitatievraag

Sollicitatiegesprek voor de functie Applications Support Engineering

-

MathWorks

What is a null pointer?

Antwoord

Antwoorden op sollicitatievragen

6 antwoorden

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)

Anoniem op

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]

Anoniem op

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.

Anoniem op

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"

Anoniem op

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.

Anoniem op

1

A pointer that points to nowhere or an empty location.

Anoniem op

Voeg antwoorden of opmerkingen toe

Meld u aan of registreer u om hier een opmerking over te maken.