Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!zardoz.cpd.com!dhw68k!felix!arcturus!evil From: evil@arcturus.uucp (Wade Guthrie) Newsgroups: comp.lang.c Subject: Re: NULL as a string terminator Message-ID: <1990Aug7.210152.7586@arcturus.uucp> Date: 7 Aug 90 21:01:52 GMT Organization: Rockwell International Lines: 33 Gary Duzan writes: >=> char command[15]; >=> command[strlen(command)-1]=NULL; /* chop off the \n */ and Doug Gwyn says: > You're correct; the example code would happen to work with the traditional > definition of NULL as plain 0, but not if it's defined as ((void*)0). That is why I have made it a practice to define a macro: #define NULLchar '\0' in order to reduce the confusion/broken code. One thing that I find helpful is to have a header file called "global.h" or "wade.h" that has a bunch of definitions I use in all my code. This file is included by every C file and has things in it like: #define YES 1 #define NO 0 #ifdef MAIN_MODULE int my_debug = 0; #else extern int my_debug; #endif I find this to be very useful (the file is actually quite a bit bigger than this, but I don't think anyone really cares. . .) -- Wade Guthrie (evil@arcturus.UUCP) | "He gasped in terror at what sounded Rockwell International; Anaheim, CA | like a man trying to gargle while My opinions, not my employer's. | fighting off a pack of wolves" | Hitchhiker's Guide