NULL in C/C++
As far as I know, NULL is just another name for 0
It is not. If you look here, you will see that NULL is defined in all of:
<stddef.h><string.h><wchar.h><time.h><locale.h><stdio.h><stdlib.h>
It is also defined in all of:
<clocale><cstddef><cstdio><cstdlib><cstring><ctime><cwchar>
You&apo;ll also find NULL defined in a lot of 3rd party libraries.
And in all instances it is IMPLEMENTATION DEFINED. It&apo;s not at all unreasonable to find #define NULL ((void*)(0)) or #define NULL ((char*)(0)) or any other such nonsense, both of which are both incorrect and not the same thing.
Problems arose when, for a misplaced sense of brevity, K&R decided to reuse integer zero in a different context, where null doesn&apo;t mean the same thing. I guess this saved them some punch card space, but it introduced a lot of misunderstanding and conflation of what both null and pointers are, and we&apo;ve been dealing with this confusion as a source of bugs and exploits ever since. Then Bjarne admits he made the same mistake when declaring pure virtual methods as equal to zero.
There are many scenarios that can arise where you mean an integer and get a null pointer, or want a null pointer and get an integer. nullptr is type safe. Never use NULL, there is no scenario where it is necessary or preferred, not even for backward compatibility or when interfacing with a C library.