G
G Fernandes
Hello fellow C-goers,
Comparisons of pointer variables to 0 are automatically converted to
comparisons to NULL (which can be represented at the bit level but
something non-zero).
But how about using !ptr or ptr in test conditions (of loops, if or ?
?
For example:
char *ptr = malloc(1);
if(!ptr)
{
/*code*/
}
It works for me, but I happen to know that my implementation uses zeros
to represent NULL. Will this be portable to systems that don't have
zero based NULL?
Thanking in advance.
Comparisons of pointer variables to 0 are automatically converted to
comparisons to NULL (which can be represented at the bit level but
something non-zero).
But how about using !ptr or ptr in test conditions (of loops, if or ?
?
For example:
char *ptr = malloc(1);
if(!ptr)
{
/*code*/
}
It works for me, but I happen to know that my implementation uses zeros
to represent NULL. Will this be portable to systems that don't have
zero based NULL?
Thanking in advance.