NULL as a string terminator

D'Arcy J.M. Cain darcy at druid.uucp
Sat Aug 11 00:03:14 AEST 1990


In article <1990Aug7.210152.7586 at arcturus.uucp> evil at arcturus.uucp (Wade Guthrie) writes:
>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'
>
Can someone explain to me what is wrong with using '\0' or even 0 when a
zero byte is required.  Is there ever a possibility that NULLchar or
whatever will evaluate to anything but a zero byte.  Perhaps this is for
people who get paid by the line of code.

Let's see.  If I was paid by the line of code ...

#define IF if
#define ELSE else
#define LOOP_WHILE_STATEMENT_TRUE(x) while(x)
#define DO_IF_STATEMENT_TRUE(x) IF(x)
etc

I bet I could turn "Hello, world" into a major GNU project. :-)

-- 
D'Arcy J.M. Cain (darcy at druid)     |
D'Arcy Cain Consulting             |   MS-DOS:  The Andrew Dice Clay
West Hill, Ontario, Canada         |   of operating systems.
+ 416 281 6094                     |



More information about the Comp.lang.c mailing list