I am wondering if anyone can please summarize the differences among the following ways of writing a conditional statement involving a pointer:
if(p)
if(p != 0)
if(p != NULL)
I am often confused at the following situations (there must be more, please supplement with yours) when to use which:
static char *p1;
char *p2 = new char();
const char *p3 = "hello"; /*then I repeatedly do p3++*/
char *p4 = 0;
char *p5 = NULL;
Edit
Also, I'd like to know, for char *p
, do we have while(*p)
or while(*p!=0)
, possibly equivalent to while(p)
or while(p!=0)
or while(p!=NULL)
or while(*p!='\0')
(or any other?) after some p++
inside the while loop?