What is the use of null pointer..? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What is the use of null pointer..?

Clarify in a simple way.

22nd Apr 2018, 3:03 PM
Sai Aravind ch
Sai Aravind ch - avatar
3 Answers
+ 13
When referring to computer memory, a null pointer is a command used to direct a software program or operating system to an empty location in the computer memory. Commonly, the null pointer is used to denote the end of a memory search or processing event. In computer programming, a null pointer is a pointer that does not point to any object or function. A nil pointer is a false value. For example, 1 > 2 is a nil statement. In the programming language C, NULL is an available command that can be used, where nil is an available command used in the Pascal programming language. SOURCE: https://www.computerhope.com/jargon/n/nullpoin.htm
22nd Apr 2018, 6:21 PM
Baraa AB
Baraa AB - avatar
+ 6
When you have pointers to stuff, you need a way to tell that your pointer isn't currently pointing at something. nullptr is that way. By changing your pointer to nullptr, you inform your code that it isn't currently valid. While nullptr is normally 0, it isn't a guarentee so always use the symbol.
22nd Apr 2018, 3:20 PM
John Wells
John Wells - avatar
+ 2
A null pointer is used in cases where a pointer is not assigned a valid address in the memory
25th Apr 2018, 7:50 PM
eMBee
eMBee - avatar