masoud khanlo masoud khanlo - 5 months ago 40
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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download