Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10 5/3/83; site bbncca.ARPA
Path: utzoo!linus!bbncca!keesan
From: keesan@bbncca.ARPA (Morris Keesan)
Newsgroups: net.lang.c
Subject: Re: sizeof "string"
Message-ID: <564@bbncca.ARPA>
Date: Fri, 10-Feb-84 10:18:54 EST
Article-I.D.: bbncca.564
Posted: Fri Feb 10 10:18:54 1984
Date-Received: Sat, 11-Feb-84 03:52:02 EST
References: <270@inuxh.UUCP>
Organization: Bolt, Beranek and Newman, Cambridge, Ma.
Lines: 23

----------------------------

    slb@inuxh.UUCP (Stephen Browning) asks,

>	Is "Hello\0, world." a string, or is it two strings?
>	Put another way, is '\0' a legal character to embed
>	within a string?

The answer is "Yes, of course," to both questions.  Section 2.5 of the C
Reference Manual (p. 181 of K&R) says "A string is a sequence of characters
surrounded by double quotes," and "The compiler places a null byte \0 at the end
of each string so that programs which scan the string can find its end." This
puts absolutely no restrictions on the contents of a string, except that the
last character will always be '\0'.  The idea that a NUL character always
indicates the end of a string is strictly a matter of convention.  One should
not confuse definitions used by library routines with the definition of a
language.  In particular, the manual page string(3), which says, "The arguments
. . . point to strings (arrays of characters terminated by a null character),"
should be ignored for the purposes of any discussion of the definition of C. 
-- 
					Morris M. Keesan
					{decvax,linus,wjh12}!bbncca!keesan
					keesan @ BBN-UNIX.ARPA