Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!mit-eddie!uw-beaver!cornell!rochester!pt.cs.cmu.edu!sei!sei.cmu.edu!firth From: firth@sei.cmu.edu (Robert Firth) Newsgroups: comp.arch Subject: Re: String lengths Message-ID: <8442@aw.sei.cmu.edu> Date: 6 Feb 89 13:33:15 GMT References: <8876@alice.UUCP> Sender: netnews@sei.cmu.edu Reply-To: firth@bd.sei.cmu.edu (Robert Firth) Organization: Carnegie-Mellon University, SEI, Pgh, Pa Lines: 22 In article <8876@alice.UUCP> dmr@alice.UUCP writes: ["strings" in C] >Given the explicit use of character arrays, and explicit pointers to >sequences of characters, the conventional use of a terminating >marker is hard to avoid. The history of this convention and >of the general array scheme had little to do with the PDP-11; it >was inherited from BCPL and B. A correction here: the C scheme was NOT inherited from BCPL. BCPL strings are not confused with character arrays; their implemetation is not normally visible to the programmer, and their semantics are respectably robust. Much the most common implementation is the one proposed earlier - have an initial length count followed by exactly that number of characters. Naturally, all characters are legal, including NUL. There are several reasons for the C 'design', but that its perpetrators didn't know any better isn't one of them.