Messages in this thread |  | | From | Mark Eichin <> | Subject | Re: NULL strings cause "segmenation fault" | Date | 24 Sep 1996 04:40:19 -0400 |
| |
> It seems that if s or t are NULL pointers (as they are when first > allocated) then I get the fault. According to the MAN page on strcmp, if > s or t are NULL then they are treated as if they point to NULL-terminated > string. So I shouldn't have to check for this in my program.
1) char *s; doesn't *initialize* s to anything -- it just makes it use some space... which may have a random value in it. That alone would crash strcmp.
2) I've never seen a strcmp which was actually documented as treeting NULL pointers specially. In particular, no linux version is documented this way.
> I tried updating the compiler from GCC 2.6.3 to 2.7.2 - no help. I tried
Time to update your C programming textbook :-)
|  |