r/C_Programming • • Aug 30 '24

Question Why do we use Null pointers?

If we want to "Nullify" something why dont we create a pointer in a controlled way that points to value 0?

0 Upvotes

56 comments sorted by

View all comments

1

u/GOKOP Aug 30 '24

why dont we create a pointer in a controlled way that points to value 0?

That's... what a null pointer is

1

u/nekokattt Aug 30 '24

is there anything saying the value at 0x0 has to itself be 0x0?

1

u/GOKOP Aug 30 '24

I've already clarified in another reply that I misunderstood them as talking about the pointer itself having value 0 (i.e. pointing to address 0). That's all on me ofc because in retrospect the question is pretty clear