masoud khanlo masoud khanlo - 25 days ago 9
C++ Question

null pointer doesn't address to 0x0 location in cpp

I want to evaluate a pointer is null or not by an if condition like below :

Model * model;
if(model == nullptr){
//do something...

But this does not work, Strangly the model pointer instead of pointing to
location it points to 0xcdcdcdcdcdcdcdcd memory location then
doesn't work for that , i also did
if(model== NULL)
these are also not working!

any idea about this problem ?

Answer Source

An uninitialized pointer need not point to NULL. It can point anywhere.