Quote:
|
Originally Posted by Jimbo
Why not? It's a silly way of doing things, but what's stopping you?
|
Well, it can be done - but the compiler should throw up a warning about a comparison between different types; in this case, a pointer and an integer.
Hmm, it doesn't seem to throw a warning for my last case, but it does for this:
int main(int argc, char *argv[])
{
char * ptr = NULL;
char ch = '\0';
ptr = &ch;
if ( *ptr == NULL )
{
printf("null\n");
}
system("PAUSE");
return 0;
}
Does this mean it is valid to compare a pointer with '\0', but not a character variable with NULL? So, NULL is only for pointers - but pointers can be used with either comparison. Stupid discrepancies.
Quote:
|
Originally Posted by Jimbo
I wouldn't say that it's bad practice, as it really depends on the algorithm.
|
And yeh, hence my second edit.
