I have recently read Can I use NULL as substitution for the value of 0?
In short, in answers it was mentioned that using NULL as a substitution for the value of 0 is not suggested and will to lead to UB.
But in Is it safe to assume that the NULL constant is zero?, in short it was said that assuming if(!ptr)//ptr is a pointer is not completely wrong.
I know the question contents are different, but how could this be explained that using NULL as substitution for 0 is wrong , while if(!ptr) is true?
Because if(!ptr) is equivalent to if(ptr==0) (I assume this is right, not sure).
Also, I have used if(ptr==0) and it never worked wrong for me (to check if ptr is NULL), and I have assigned 0 to pointer ptr and when I debugged my code ptr was NULL. Are these two experiences safe?