Path: utzoo!mnetor!uunet!husc6!hao!ames!umd5!uvaarpa!mcnc!thorin!polk!leech From: leech@polk.cs.unc.edu (Jonathan Leech) Newsgroups: comp.lang.c Subject: Re: Null-terminated C strings Message-ID: <503@thorin.cs.unc.edu> Date: 24 Dec 87 20:42:46 GMT References: <174@quick.COM> <14116@think.UUCP> <2447@hall.cray.com> <3087@phri.UUCP> Sender: news@thorin.cs.unc.edu Reply-To: leech@polk.UUCP (Jonathan Leech) Organization: University Of North Carolina, Chapel Hill Lines: 21 Summary: Expires: Sender: Followup-To: Distribution: Keywords: In article <3087@phri.UUCP> roy@phri.UUCP (Roy Smith) writes: >There is nothing strictly illegal about imbedding a null in a >string constant, but it is strange. One might want to do: > > printf ("this\000probably won't print\n"+5); > >and the compiler should let you do it, although I can't think of any valid >reason offhand you would *want* to do such a thing. To let people patch site-specific data in code distributed binary-only e.g. static char *termtypes[] = { "ADM3A\0Patching area", /* VMS Foreign Terminal type FT1 */ ...etc something like this showed up in code I saw a few years ago. Jon Leech (leech@cs.unc.edu) __@/ ``...there are many places where gravity has its practical applications as far as the Universe is concerned.'' - R. P. Feynman, _The Character of Physical Law_