Mail Archives: djgpp/1997/04/19/02:15:29
Jawed Karim wrote:
> #include <stdio.h>
>
> void main(void)
> {
> char *string = NULL;
>
> if (*string != NULL)
> printf("\n%s\n", string);
> }
What you're doing here is dereferencing a null pointer, which is a Bad
Thing To Do. If it crashes, it's your fault. If it doesn't, then it's
still you're fault, but the compiler is not necessarily at fault.
For what you appear to be trying to do, by the way, the correct statement
is
if (string != NULL) printf("\n%s\n", string);
Your use of *string means you're dereferencing the pointer, which is null.
Very naughty.
--
Erik Max Francis, &tSftDotIotE / email / max AT alcyone DOT com
Alcyone Systems / web / http://www.alcyone.com/max/
San Jose, California, United States / icbm / 37 20 07 N 121 53 38 W
\
"The future / is right there."
/ Bill Moyers
- Raw text -