NULL as a string terminator

Robert J. Drabek robert at cs.arizona.edu
Sat Aug 11 10:45:20 AEST 1990


D'Arcy J.M. Cain writes:

> Wade Guthrie writes:
> >I have made it a practice to define a macro:
> >#define  EOS  '\0'

> Can someone explain to me what is wrong with using '\0' or even 0 when a
> zero byte is required.  Perhaps this is for people who get paid by the 
> line of code.

Nothing really `wrong' with it.  I see the difference as one between
using an object and using a name for the object.  My personal feeling is
that it is more polite to use the name.  Or maybe it's like licking your
lips and rubbing your stomach instead of expressing yourself in words.
(Forgive me, but it's 5:30 pm and I should be heading home for dinner.)

Also, EOS is easier for me to type when changing from one keyboard to
another as the ', \, and 0 often vary in position and are all further
from the home row.  But even if I had an abbreviation set up (in vi) I'd
still like to read the EOS instead.

The reason why requires maybe one last explanation which is more
objective.  '\0' has uses and interpretations other than "end-of-
string".  So when I see EOS I know for certain what I meant.  When I see
'\0' there is the chance that some other interpretation or use is meant.

--
-- 
Robert J. Drabek                            robert at cs.Arizona.EDU
Department of Computer Science              uunet!arizona!robert
The University of Arizona                   602 621 4326
Tucson, AZ  85721



More information about the Comp.lang.c mailing list