NULL as a string terminator

Michael Meissner meissner at osf.org
Sat Aug 11 01:00:52 AEST 1990


In article <1990Aug7.210152.7586 at arcturus.uucp> evil at arcturus.uucp
(Wade Guthrie) writes:

| 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'

I really don't understand why the NULLchar macro is any clearer than
just '\0'.  But then, I really have never seen the need for NULL
either (the appropriate cast of 0 works just as well -- if you have
problems with the shift key, then maybe you should learn to type :-)
--
Michael Meissner	email: meissner at osf.org		phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142

Do apple growers tell their kids money doesn't grow on bushes?



More information about the Comp.lang.c mailing list